我正在学习本教程,因为我是 Webpack 的新手……我的 webpack.config.js 是:
module.exports = {
entry: "./app/entry",
mode: "development",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
}
};
我的package.json
:
{
"name": "pruebaWebpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"webpack": "^4.4.1",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.1"
},
"dependencies": {
"react": "^16.3.0",
"react-dom": "^16.3.0"
}
}
但显然它忽略了我的配置文件,因为当我运行时npm run build
它使用默认路径(entry = ./src y output = ./dist)并且不识别模式属性:
pruebaWebpack@1.0.0 build /opt/lampp/htdocs/pruebaWebpack
网页包
哈希:4a9c3de0f194dd38ac70 版本:webpack 4.4.1
时间:234ms
建于:2018-4-1 15:53:00 Asset Size Chunks
Chunk名称 main.js 564 bytes 0 [emitted] main Entrypoint main = main.js [0] ./src/index.js 19 bytes {0} [built]
配置中的警告 'mode' 选项尚未设置,webpack 将回退到此值的 'production'。将“模式”选项设置为“开发”或“生产”以启用每个环境的默认值。您还可以将其设置为“无”以禁用任何默认行为。了解更多:https ://webpack.js.org/concepts/mode/
在此先感谢并为我的英语感到抱歉。