feat: remove/clean your build folder(s) before building

This commit is contained in:
endiliey 2018-08-23 23:07:24 +08:00
parent 406106b67e
commit e13e1bffb4
3 changed files with 13 additions and 0 deletions

View file

@ -1,6 +1,7 @@
const path = require('path');
const webpackNiceLog = require('webpack-nicelog');
const {StatsWriterPlugin} = require('webpack-stats-plugin');
const cleanWebpackPlugin = require('clean-webpack-plugin');
const createBaseConfig = require('./base');
module.exports = function createClientConfig(props) {
@ -8,6 +9,11 @@ module.exports = function createClientConfig(props) {
config.entry('main').add(path.resolve(__dirname, '../core/clientEntry.js'));
const {outDir} = props;
config
.plugin('clean')
.use(cleanWebpackPlugin, [outDir, {verbose: false, allowExternal: true}]);
// write webpack stats object to a file so we can
// programmatically refer to the correct bundle path in Node.js server.
config

View file

@ -48,6 +48,7 @@
"babel-preset-react": "^6.24.1",
"chalk": "^2.4.1",
"chokidar": "^2.0.4",
"clean-webpack-plugin": "^0.1.19",
"commander": "^2.16.0",
"connect-history-api-fallback": "^1.5.0",
"css-loader": "^1.0.0",

View file

@ -1521,6 +1521,12 @@ clean-css@4.1.x:
dependencies:
source-map "0.5.x"
clean-webpack-plugin@^0.1.19:
version "0.1.19"
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-0.1.19.tgz#ceda8bb96b00fe168e9b080272960d20fdcadd6d"
dependencies:
rimraf "^2.6.1"
cli-boxes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143"