我不明白为什么我的项目中没有读取webpack-config.js。
如果我在webpack-config.js中犯了一些语法错误,它甚至不会显示该错误。
这里是 package.json :
{
"name": "ff",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --mode development --hot --progress --open",
"build": "webpack --mode production"
},
"author": "",
"license": "MIT",
"devDependencies": {
"path": "^0.12.7",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"jquery": "^3.3.1"
}
}
这是我的 webpack-config.js :
const path = require('path');
const conf = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'main.js',
publicPath: 'dist/'
},
devServer: {
overlay:true
}
};
module.exports = conf;
答案 0 :(得分:2)
可能您使用了错误的文件名-webpack正在寻找“ webpack.config.js”文件,但您有“ webpack-config.js”(用短划线代替点号)。尝试重命名或帮助Webpack通过使用--config选项显式设置配置路径来找到它