当我使用 webpack-dev-server 时,Webpack4不会使用文件 main.js 创建文件夹'dist'。
我的 package.json
{
"name": "webpack-project",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --mode development --open",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"path": "^0.12.7",
"webpack": "^4.20.1",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.9"
},
"dependencies": {}
}
我的 webpack.config.js
const path = require('path');
module.export = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'main.js',
publicPath: 'dist/'
}
}
但是,如果 package.json 文件中存在"dev": "webpack --mode production"
,则会创建带有 main.js 文件的文件夹“ dist”。
为什么在使用 webpack-dev-server 时它不起作用?
答案 0 :(得分:0)