當我運行命令「webpack」 - everyting好,但是當我運行「webpack-dev-server -content-base src -inline -hot」 - 我得到錯誤。 可能是sytax錯誤,我打賭我找不到問題。問題與webpack.config.js
C:\wamp\www\react\node_modules\webpack\lib\NormalModuleFactory.js:72
var elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
^
TypeError: Cannot read property 'replace' of undefined
at C:\wamp\www\react\node_modules\webpack\lib\NormalModuleFactory.js:72:26
at C:\wamp\www\react\node_modules\webpack\lib\NormalModuleFactory.js:28:4
at C:\wamp\www\react\node_modules\webpack\lib\NormalModuleFactory.js:159:3
at NormalModuleFactory.applyPluginsAsyncWaterfall (C:\wamp\www\react\node_modules\webpack\node_modules\tapable\lib\Tapable.js:75:69)
at NormalModuleFactory.create (C:\wamp\www\react\node_modules\webpack\lib\NormalModuleFactory.js:144:8)
at C:\wamp\www\react\node_modules\webpack\lib\Compilation.js:214:11
at C:\wamp\www\react\node_modules\webpack\node_modules\async\lib\async.js:181:20
at Object.async.forEachOf.async.eachOf (C:\wamp\www\react\node_modules\webpack\node_modules\async\lib\async.js:233:13)
at Object.async.forEach.async.each (C:\wamp\www\react\node_modules\webpack\node_modules\async\lib\async.js:209:22)
at Compilation.addModuleDependencies (C:\wamp\www\react\node_modules\webpack\lib\Compilation.js:185:8)
我的配置:
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname+"/resources/assets/js",
devtool: debug ? "inline-sourcemap" : null,
entry: "./test.jsx",
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
}
]
},
output: {
path: __dirname + "/public/js",
filename: "scripts.min.js"
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false })
]
};
目錄結構:
C:\wamp\www\react\public\js\ - output
C:\wamp\www\react\resources\assets\js\ - srouce (ex. test.jsx)
C:\wamp\www\react\node_modules\ - node modules
C:\wamp\www\react\ - root directory (ex. webpack.config.js)
Please post your directory structure – Steffen
沒有足夠的信息來說明任何結論。 –
Steffen>更新了,請看看。 bebraw>你需要什麼樣的數據? – lolalola