Skip to content

Commit c393a8d

Browse files
chore: Add CleanWebpackPlugin to webpack prod
1 parent fbf1284 commit c393a8d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

config/webpack.config.prod.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
const webpack = require('webpack');
2+
const path = require('path');
23
const merge = require('webpack-merge');
34
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
45
const ExtractTextPlugin = require('extract-text-webpack-plugin');
56
const CompressionPlugin = require('compression-webpack-plugin');
7+
const CleanWebpackPlugin = require('clean-webpack-plugin');
68
const common = require('./webpack.config.common');
79

10+
const distDir = path.resolve(__dirname, '..', 'dist');
11+
812
const extractSass = new ExtractTextPlugin({
913
filename: '[name].[contenthash].css',
1014
disable: process.env.NODE_ENV === 'development',
@@ -33,6 +37,11 @@ module.exports = merge.smart(common, {
3337
},
3438

3539
plugins: [
40+
new CleanWebpackPlugin([distDir], {
41+
root: path.resolve(__dirname, '..'),
42+
verbose: true,
43+
dry: false,
44+
}),
3645
new UglifyJSPlugin({
3746
sourceMap: true,
3847
uglifyOptions: { ecma: 8 },

0 commit comments

Comments
 (0)