一个webpack插件,在构建之前删除你的构建文件夹
安装
1
| npm i clean-webpack-plugin --save-dev
|
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| const CleanWebpackPlugin = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const webpack = require('webpack'); const path = require('path'); let pathsToClean = [ 'dist', 'build' ] let cleanOptions = { root: '/full/webpack/root/path', exclude: ['shared.js'], verbose: true, dry: false } const webpackConfig = { entry: './path/to/my/entry/file.js', output: { filename: 'my-first-webpack.bundle.js', path: path.resolve(__dirname, 'dist') }, module: { rules: [ { test: /\.(js|jsx)$/, loader: 'babel-loader' } ] }, plugins: [ new CleanWebpackPlugin(pathsToClean, cleanOptions), new webpack.optimize.UglifyJsPlugin(), new HtmlWebpackPlugin({template: './src/index.html'}) ] } Paths
|