From c791be01b972b06ca67b4f59d83bbcbef404f87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A1=B9=E4=BC=9F=E5=B9=B3?= Date: Mon, 23 Oct 2017 10:22:53 +0800 Subject: [PATCH] add unit test: add webpack 2 unit test --- package.json | 7 +++--- .../{webpack.config.js => webpack1.config.js} | 2 +- test/webpack2.config.js | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) rename test/{webpack.config.js => webpack1.config.js} (91%) create mode 100644 test/webpack2.config.js diff --git a/package.json b/package.json index 1e6e348..c90c464 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "EJS webpack loader (without frontend dependencies)", "main": "index.js", "scripts": { - "test": "cd test && ../node_modules/.bin/webpack && node bundle.js" + "test": "npm run test:webpack1 && npm run test:webpack2", + "test:webpack1": "npm install -q webpack@1.x && webpack --config test/webpack1.config.js && node test/bundle.js", + "test:webpack2": "npm install -q webpack@2.x && webpack --config test/webpack2.config.js && node test/bundle.js" }, "repository": { "type": "git", @@ -30,7 +32,6 @@ "uglify-js": "~2.6.1" }, "devDependencies": { - "node-libs-browser": "^0.5.0", - "webpack": "^1.9.4" + "node-libs-browser": "^0.5.0" } } diff --git a/test/webpack.config.js b/test/webpack1.config.js similarity index 91% rename from test/webpack.config.js rename to test/webpack1.config.js index 24ecb07..cf37fc1 100644 --- a/test/webpack.config.js +++ b/test/webpack1.config.js @@ -1,5 +1,5 @@ module.exports = { - entry: "./app.js", + entry: "./test/app.js", cache: false, output: { path: __dirname, diff --git a/test/webpack2.config.js b/test/webpack2.config.js new file mode 100644 index 0000000..299532b --- /dev/null +++ b/test/webpack2.config.js @@ -0,0 +1,23 @@ +module.exports = { + entry: "./test/app.js", + cache: false, + output: { + path: __dirname, + filename: "bundle.js" + }, + module: { + rules: [{ + test: /\.(ejs)$/, + use: { + loader: require.resolve('../'), + options: { + htmlmin: true, + htmlminOptions: { + removeComments: true, + } + }, + }, + }] + } + +}