Skip to content

Commit

Permalink
feat: add vconsole-webpack-plugin, default disable
Browse files Browse the repository at this point in the history
  • Loading branch information
sky committed Nov 4, 2019
1 parent 5bf07e7 commit 800898b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 25 additions & 0 deletions test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});

0 comments on commit 800898b

Please sign in to comment.