The build directory was deleted by clean-webpack-plugin when webpack 4 started webpack-dev-server

< H2 > question < / H2 > In the

project, I first cooperate with NPM to execute the webpack command to build the code, in which clean-webpack-plugin is used to delete the previous build results before generating a new one.

After

, I use the webpack-dev-server-- open command with NPM to start the server, but at this time, clean-webpack-plugin will also be executed, and then the build directory generated when I first executed the webpack command will be deleted. What should I do?

< H2 > Code < / H2 >

package.json

"scripts": {
    "start": "webpack-dev-server --open",
    "build": "webpack",
 },

webpack.config.js

plugins: [
    // 
    new CleanWebpackPlugin([path.join(__dirname, "build")]),
],

devServer: {
    contentBase: "./build",
},
Mar.09,2021

the config, of configuring webpack separately is divided into webpack.prod , webpack.base , and webpack.dev . I don't think 0 configuration is of any use.

or set the environment variable

"dev": "NODE_ENV=development webpack-dev-server"

if (process.env.NODE_ENV === 'development') {
    // xxxx
}

env-cross package for windows and mac compatibility

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45520-59b73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45520-59b73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?