设置我的Webpack配置文件时,获取错误的“ index.html” = index.html的Entrypoint html-webpack-plugin

时间:2019-01-09 08:47:00

标签: javascript reactjs webpack

我已经开始学习react js,但是我被困在设置webpackconfig.file中。我遇到以下错误:

Child html-webpack-plugin for "index.html":
 1 asset
Entrypoint html-webpack-plugin for "index.html" = index.html

webpack配置文件:

        const path = require('path');
        const HtmlWebpackPlugin = require('html-webpack-plugin');

        module.exports = {
                          entry: './src/main.js',
                          output: {
                                   path.join(__dirname, '/bundle'),
                                   filename: 'index_bundle.js'
                                  },
                           devServer: {
                                   inline: true,
                                   port: 8080
                                  },
                           module: {
                                     rules: [
                                                {
                                                  test: /\.jsx?$/,
                                                  exclude: /node_modules/,
                                                  loader: 'babel-loader',
                                                  query: {
                                                           presets: ['es2015', 'react']
                                                   }
                                                 }
                                               ]
                                         },
                             plugins:[
                                      new HtmlWebpackPlugin({
                                      template: './index.html'
                                      })
                                     ]
                          }

通过搜索,这可能是webpackplugins中的问题

package.json文件:

    {                
      "name": "reactApp",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
                  "start": "webpack-dev-server --mode development --open --hot",
                  "build": "webpack --mode production"
   },
   "keywords": [],
   "author": "",
   "license": "ISC",
   "dependencies": {
                     "react": "^16.7.0",
                     "react-dom": "^16.7.0",
                     "webpack-cli": "^3.2.1",
                     "webpack-dev-server": "^3.1.14"
   },
  "devDependencies": {
  "babel-core": "^6.26.3",
  "babel-loader": "^7.1.5",
  "babel-preset-env": "^1.7.0",
  "babel-preset-react": "^6.24.1",
  "html-loader": "^0.5.5",
  "html-webpack-plugin": "^3.0.7",
   "webpack": "^4.28.1"
}

我的每个文件(index.html,main.js,pacage.json,webpacconfig.js,.babelrc)都位于同一文件夹中,我无法检测出实际的问题,

0 个答案:

没有答案