Skip to content

Commit 1298e3c

Browse files
committed
cleanup webpack build folder
1 parent 3c89955 commit 1298e3c

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ module.exports = function (grunt) {
5656
plugins: require("./webpack.config.js").prodPlugins
5757
},
5858
dev: {
59-
cache: false
59+
cache: false,
60+
plugins: require("./webpack.config.js").devPlugins
6061
}
6162
},
6263
copy: {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"babel-loader": "^6.2.10",
2828
"babel-preset-es2015": "^6.5.0",
2929
"babelify": "^6.1.0",
30+
"clean-webpack-plugin": "^0.1.15",
3031
"express": "~3.4.8",
3132
"grunt": "~0.4.5",
3233
"grunt-contrib-connect": "~0.10.1",

webpack.config.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var path = require('path');
22
var webpack = require('webpack');
3-
var packageJSON = require('./package.json');
43

54
module.exports.config = {
65
entry: {
@@ -26,13 +25,33 @@ module.exports.config = {
2625
}
2726
};
2827

28+
/**** plugins ****/
29+
30+
var packageJSON = require('./package.json');
31+
var CleanWebpackPlugin = require('clean-webpack-plugin');
32+
2933
var banner =
3034
packageJSON.name + '\n' +
3135
packageJSON.homepage + '\n' +
3236
'Version: ' + packageJSON.version + ' -- ' + (new Date()).toISOString() + '\n' +
3337
'License: ' + packageJSON.license;
3438

35-
module.exports.prodPlugins = [
39+
var plugins = [
40+
new CleanWebpackPlugin(['temp'], {
41+
root: process.cwd(),
42+
verbose: true,
43+
dry: false,
44+
})
45+
];
46+
47+
module.exports.devPlugins = plugins;
48+
49+
module.exports.prodPlugins = plugins.concat([
50+
new CleanWebpackPlugin(['temp'], {
51+
root: process.cwd(),
52+
verbose: true,
53+
dry: false,
54+
}),
3655
new webpack.optimize.UglifyJsPlugin({
3756
compress: {
3857
warnings: true,
@@ -42,4 +61,4 @@ module.exports.prodPlugins = [
4261
},
4362
}),
4463
new webpack.BannerPlugin(banner)
45-
];
64+
]);

0 commit comments

Comments
 (0)