我按照这个例子(http://courses.reactjsprogram.com/courses/reactjsfundamentals/lectures/760301)来启动一个reactj应用程序,所以这是我的webpack.config.js
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
tempalte : __dirname + '/app/index.html',
filename : 'index.html',
inject : 'body'
})
module.exports = {
entry: [
'./app/index.js'
],
output: {
path : __dirname + '/dist',
filename : "index_bundle.js"
},
module : {
loaders :[
{test: /\.js$/, include: __dirname + '/app', loader: "babel-loader"}
]
},
plugins : [HtmlWebpackPluginConfig]
}
这是我的 index.html 模板:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> teste</title>
</head>
<body>
<div id="app"></div>
</body>
</html>
这是我由 webpack 生成的 index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Webpack App</title>
</head>
<body>
<script src="index_bundle.js"></script></body>
</html>
注意:我的已被删除,因此当我尝试运行我的应用程序时出现错误:
Uncaught Invariant Violation: _registerComponent(...): Target container is not a DOM element.
如何修复不删除我的 div?我使用“babel-core”:“^6.7.6”、“babel-loader”:“^6.2.4”、“babel-preset-react”:“^6.5.0”、“html-webpack-plugin” :“^2.15.0”、“webpack”:“^1.13.0”、“webpack-dev-server”:“^1.14.1”
tks