From 800898b4916369543ad72b3fb995068bba61809e Mon Sep 17 00:00:00 2001 From: sky Date: Mon, 4 Nov 2019 14:54:18 +0800 Subject: [PATCH] feat: add vconsole-webpack-plugin, default disable --- config/plugin.js | 10 ++++++++++ package.json | 1 + test/client.test.js | 25 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/config/plugin.js b/config/plugin.js index ac04bcc..f2a853f 100644 --- a/config/plugin.js +++ b/config/plugin.js @@ -277,4 +277,14 @@ exports.filter = { args: { exclude: /\[mini-css-extract-plugin]\nConflicting order between:/ } +}; + +exports.vconsole = { + enable: false, + type: 'client', + name: 'vconsole-webpack-plugin', + args() { + const enable = ['dev', 'test'].indexOf(this.env) > -1; + return { enable }; + } }; \ No newline at end of file diff --git a/package.json b/package.json index e3b9ac0..5ec59ae 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "thread-loader": "^1.1.5", "uglifyjs-webpack-plugin": "^2.0.1", "url-loader": "^0.5.8", + "vconsole-webpack-plugin": "^1.4.2", "webpack-asset-file-plugin": "^1.0.0", "webpack-filter-warnings-plugin": "^1.2.0", "webpack-hot-middleware": "^2.13.2", diff --git a/test/client.test.js b/test/client.test.js index a1baf95..ed97bf7 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -516,5 +516,30 @@ describe('client.test.js', () => { const webpackConfig = builder.create(); expect(webpackConfig.externals.jquery).to.equal('jquery'); }); + it('should vconsole webpack plugin dev test', () => { + const builder = createBuilder({ + plugins:[ + { + vconsole: true + } + ] + }); + const webpackConfig = builder.create(); + const vconsole = helper.getPluginByLabel('vconsole', webpackConfig.plugins); + expect(vconsole.options.enable).to.be.true; + }); + it('should vconsole webpack plugin prod test', () => { + const builder = createBuilder({ + env: 'prod', + plugins:[ + { + vconsole: true + } + ] + }); + const webpackConfig = builder.create(); + const vconsole = helper.getPluginByLabel('vconsole', webpackConfig.plugins); + expect(vconsole.options.enable).to.be.false; + }); }); }); \ No newline at end of file