Mahesh
Mahesh

Reputation: 863

Invalid configuration error while creating a react app with webpack configuration

Unable to configure webpack with react

below is error :

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.entry['main'] should not contain the item '—' twice. -> A non-empty array of non-empty strings

I have configured webpack and tried

below is webpack.config.js

 const path = require('path');
 const HWP = require('html-webpack-plugin');
 module.exports = {
   entry: path.join(__dirname, '/src/index.js'),
    output: {
    filename: 'build.js',
    path: path.join(__dirname, '/dist')},
module:{
   rules:[{
       test: /\.js$/,
      exclude: /node_modules/,
       loader: 'babel-loader'
    }]
  },
  plugins:[
    new HWP(
       {template: path.join(__dirname,'/src/index.html')}
   )
  ]
}

enter image description here

enter image description here

Upvotes: 1

Views: 2704

Answers (3)

Lucas Urriste
Lucas Urriste

Reputation: 19

I solve this adding "--live-reload false" to my start command.

"scripts": {

"ng": "ng",
"start": "ng serve --live-reload false",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"build:single-spa:mf-test2": "ng build mf-test2 --prod",
"serve:single-spa:mf-test2": "ng s --project mf-test2 --disable-host-check --port NaN --live-reload false"   },

Upvotes: 2

Mahesh
Mahesh

Reputation: 863

changing scripts start command in package.json as below made it working,

"start": "webpack-dev-server --config webpack.config.js --port 3000",

Upvotes: 0

Jasper Bernales
Jasper Bernales

Reputation: 1681

i think this will work

 const path = require('path');
 const HWP = require('html-webpack-plugin');
 module.exports = {
   entry: ['./src/index.js'],
    output: {
    filename: 'build.js',
    path: path.join(__dirname, 'dist')},
module:{
   rules:[{
       test: /\.js$/,
      exclude: /node_modules/,
       loader: 'babel-loader'
    }]
  },
  plugins:[
    new HWP(
       {template: path.join(__dirname,'src/index.html')}
   )
  ]
}

Upvotes: 0

Related Questions