Skip to content

Commit 800898b

Browse files
author
sky
committed
feat: add vconsole-webpack-plugin, default disable
1 parent 5bf07e7 commit 800898b

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

config/plugin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,14 @@ exports.filter = {
277277
args: {
278278
exclude: /\[mini-css-extract-plugin]\nConflicting order between:/
279279
}
280+
};
281+
282+
exports.vconsole = {
283+
enable: false,
284+
type: 'client',
285+
name: 'vconsole-webpack-plugin',
286+
args() {
287+
const enable = ['dev', 'test'].indexOf(this.env) > -1;
288+
return { enable };
289+
}
280290
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"thread-loader": "^1.1.5",
6161
"uglifyjs-webpack-plugin": "^2.0.1",
6262
"url-loader": "^0.5.8",
63+
"vconsole-webpack-plugin": "^1.4.2",
6364
"webpack-asset-file-plugin": "^1.0.0",
6465
"webpack-filter-warnings-plugin": "^1.2.0",
6566
"webpack-hot-middleware": "^2.13.2",

test/client.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,30 @@ describe('client.test.js', () => {
516516
const webpackConfig = builder.create();
517517
expect(webpackConfig.externals.jquery).to.equal('jquery');
518518
});
519+
it('should vconsole webpack plugin dev test', () => {
520+
const builder = createBuilder({
521+
plugins:[
522+
{
523+
vconsole: true
524+
}
525+
]
526+
});
527+
const webpackConfig = builder.create();
528+
const vconsole = helper.getPluginByLabel('vconsole', webpackConfig.plugins);
529+
expect(vconsole.options.enable).to.be.true;
530+
});
531+
it('should vconsole webpack plugin prod test', () => {
532+
const builder = createBuilder({
533+
env: 'prod',
534+
plugins:[
535+
{
536+
vconsole: true
537+
}
538+
]
539+
});
540+
const webpackConfig = builder.create();
541+
const vconsole = helper.getPluginByLabel('vconsole', webpackConfig.plugins);
542+
expect(vconsole.options.enable).to.be.false;
543+
});
519544
});
520545
});

0 commit comments

Comments
 (0)