简体   繁体   English

HTMLWebpackPlugin擦除模板div

[英]HtmlWebpackPlugin erase template div

I follow this example( http://courses.reactjsprogram.com/courses/reactjsfundamentals/lectures/760301 ) to start one reactj app, so this is my webpack.config.js 我按照此示例( 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]
}

And this is my index.html template: 这是我的index.html模板:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> teste</title>
</head>
<body>
  <div id="app"></div>
</body>
</html>

and this is my index.html generated by webpack 这是我的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>

Note: my are removed, so when I try to run my app I got the error: 注意:我已删除,因此当我尝试运行我的应用程序时出现错误:

Uncaught Invariant Violation: _registerComponent(...): Target container is not a DOM element.

How can I fix to don`t remove my div? 如何解决不删除div的问题? I using "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" 我使用“ 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 ks

A typo in the template key in your configuration means that it is using a default template and not the one you were trying to include. 配置中template密钥的错字表示它使用的是默认模板,而不是您尝试包含的模板。 The default behavior makes this error difficult to spot. 默认行为使此错误很难发现。

tempalte : __dirname + '/app/index.html' should be template : __dirname + '/app/index.html' tempalte : __dirname + '/app/index.html'应该是template : __dirname + '/app/index.html'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM