启动webpack-dev-server时dist目录被clean-webpack-plugin删除了

配置以下:css

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    devtool:'inline-source-map',
    mode:'development',
    entry:'./src/index.js',
    output:{
        path:path.resolve(__dirname,'dist'),
        filename:'bundle-[hash].js'
    },
    module:{
        rules:[
            {
                test:/\.css$/,
                use:'css-loader'
            }
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            title:'Hello Webpack',
            template: './src/index.html'
        }),
        new CleanWebpackPlugin(path.join(__dirname, 'dist'))
    ],
    devServer:{
        contentBase:path.join(__dirname,'dist'),
        port:5678,
        host:'0,0,0,0'
    }
}

packjson命令以下
"scripts": {
    "dev": "webpack-dev-server --open",
    "test": "echo \"Error: no test specified\" && exit 1"
},

执行命令 npm run dev 报错信息提示项目的dist目录已经被 clean-webpack-plugin 插件删除了。
有大神提点一下吗?

复制代码
相关文章
相关标签/搜索