我正在使用react
应用程序并介绍了webpack。控制台错误堆栈是指react-dom.production.min.js
一个巨大的缩小文件而不是具有未定义变量的特定文件。单独的文件已映射,但错误堆栈未引用具有错误的特定文件。
错误堆栈
ReferenceError: omak is not defined
Stack trace:
render@webpack-internal:///10:124:1
l@webpack-internal:///17:131:336
beginWork@webpack-internal:///17:138:287
e@webpack-internal:///17:176:105
f@webpack-internal:///17:176:379
G@webpack-internal:///17:182:329
x@webpack-internal:///17:181:378
n@webpack-internal:///17:181:221
B@webpack-internal:///17:180:117
v@webpack-internal:///17:179:51
b@webpack-internal:///17:190:302
updateContainer@webpack-internal:///17:191:389
tg.prototype.render@webpack-internal:///17:228:366
Eg/<@webpack-internal:///17:242:473
unbatchedUpdates@webpack-internal:///17:188:42
Eg@webpack-internal:///17:242:392
render@webpack-internal:///17:244:189
@webpack-internal:///20:19:1
@http://127.0.0.1:8080/bundle.js:217:1
__webpack_require__@http://127.0.0.1:8080/bundle.js:20:12
@http://127.0.0.1:8080/bundle.js:69:18
@http://127.0.0.1:8080/bundle.js:1:11
webpack.config.js
const path = require('path');
//const BabiliPlugin = require('babili-webpack-plugin');
module.exports = {
entry: './src/app.js',
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
},
optimization: {
minimize: false
},
module: {
rules: [{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
}]
},
devtool: 'cheap-module-eval-source-map'
}
的package.json
{
"scripts": {
"serve": "live-server public/",
"build": "webpack --watch",
"build-babel": "babel src/app.js --out-file=public/scripts/app.js --preset=env,react --watch"
},
"dependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"live-server": "^1.2.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"validator": "^10.2.0",
"webpack": "^4.8.3"
},
"devDependencies": {
"webpack-cli": "^2.1.3"
}
}
萤火虫来源