HtmlWebpackPlugin erase template div

Fabio Ebner

I follow this example(http://courses.reactjsprogram.com/courses/reactjsfundamentals/lectures/760301) to start one reactj app, so this is my 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:

<!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

<!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? 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"

tks

max

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. The default behavior makes this error difficult to spot.

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Using the same template file with HtmlWebpackPlugin and EJS?

HtmlWebpackPlugin with template adds an unwanted </html> at the end

Using nunjucks with htmlWebpackPlugin using dynamic vars in the template

Deduce/erase type of template template argument

How to use `htmlWebpackPlugin.options.title` inside Vue SFC template?

Erase the space between my div and the browser window

Why is std::erase(std::erase_if) not a template in <algorithm> that works on any container?

How to disambiguate the overloads of the `erase_all_if` function template?

Erase the space between my div and the windows from the browser

map.erase(it) causes double free when it comes from map.find in template

HtmlWebpackPlugin not working for typescript application

Combine htmlwebpackplugin chunks

Content Hashes, ExtractTextPlugin and HtmlWebpackPlugin

webpack minify HtmlWebpackPlugin

Div aligning issue in a blogspot template

Ember template without div wrapper

Make a div scrollable inside a template

Erase UIBezierPath

The affect of HtmlWebpackPlugin on webpack dev server

A clean way to loop HTMLWebpackPlugin with Webpack?

Webpack HtmlWebpackPlugin removes DOM elements

handlerbar template with backbone inside div does not render

Meteor: Reusing a Template With a Chart-Div

Dynamically finding the div rendered through the template

How to load a template into a div of a phtml file in Magento

How to show div line by line - template Angular

Angular template: Disable div in production mode

Is there a way to pass in variable to <div> id in django template?

How Scroll to a div in ng-template?