我正在安装一个反应启动应用程序并添加了 Webpack,但它说 Can't resolve './src/index.js'
。
Webpack.config.js 内容
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, "public"),
devtool: debug ? "inline-sourcemap" : false,
entry: "./src/index.js",
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2016', 'stage-0'],
plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
}
}
]
},
output: {
path: __dirname + "/public/",
filename: "build.js"
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
};
原文由 MD Ashik 发布,翻译遵循 CC BY-SA 4.0 许可协议
您的基本 URL 是
path.join(__dirname, "public")
,您的条目是./src/index.js
。 Webpack 尝试在public
目录中找到./src/index.js
;显然它不存在。您应该将entry
修改为../src/index.js
。