Skip to content

Commit b31ff66

Browse files
committed
refactor(webpack): webpack file cleanup
1 parent 3ac870a commit b31ff66

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

Diff for: templates/app/webpack.make.js

+16-19
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ module.exports = function makeWebpackConfig(options) {
1515
* BUILD is for generating minified builds
1616
* TEST is for generating test builds
1717
*/
18-
var BUILD = !!options.BUILD;
19-
var TEST = !!options.TEST;
20-
var DEV = !!options.DEV;
18+
const BUILD = !!options.BUILD;
19+
const TEST = !!options.TEST;
20+
const DEV = !!options.DEV;
2121

2222
/**
2323
* Config
2424
* Reference: http://webpack.github.io/docs/configuration.html
2525
* This is the object where all configuration gets set
2626
*/
27-
var config = {};
27+
const config = {};
2828

2929
config.mode = BUILD
3030
? 'production'
@@ -330,12 +330,10 @@ module.exports = function makeWebpackConfig(options) {
330330
babel: {
331331
<%_ if(filters.flow) { -%>
332332
shouldPrintComment(commentContents) {
333-
let regex = DEV
334-
// keep `// @flow` & flow type comments in dev
335-
? /(@flow|^:)/
336-
// strip comments
337-
: false;
338-
return regex.test(commentContents);
333+
if(!DEV) return false;
334+
335+
// keep `// @flow` & flow type comments in dev
336+
return /(@flow|^:)/.test(commentContents);
339337
},<% } %>
340338
<%_ if(!filters.flow) { -%>
341339
comments: false<% } %>
@@ -358,14 +356,13 @@ module.exports = function makeWebpackConfig(options) {
358356
// Reference: https://github.com/ampedandwired/html-webpack-plugin
359357
// Render app.html
360358
if(!TEST) {
361-
let htmlConfig = {
362-
template: 'client/app.template.html',
363-
filename: '../client/app.html',
364-
alwaysWriteToDisk: true
365-
}
366359
config.plugins.push(
367-
new HtmlWebpackPlugin(htmlConfig),
368-
new HtmlWebpackHarddiskPlugin()
360+
new HtmlWebpackPlugin({
361+
template: 'client/app.template.html',
362+
filename: '../client/app.html',
363+
alwaysWriteToDisk: true,
364+
}),
365+
new HtmlWebpackHarddiskPlugin(),
369366
);
370367
}
371368

@@ -391,7 +388,7 @@ module.exports = function makeWebpackConfig(options) {
391388

392389
if(DEV) {
393390
config.plugins.push(
394-
new webpack.HotModuleReplacementPlugin()
391+
new webpack.HotModuleReplacementPlugin(),
395392
);
396393
}
397394

@@ -466,7 +463,7 @@ module.exports = function makeWebpackConfig(options) {
466463
process: true,
467464
crypto: false,
468465
clearImmediate: false,
469-
setImmediate: false
466+
setImmediate: false,
470467
};
471468

472469
return config;

0 commit comments

Comments
 (0)