无法使用react配置webpack
下面是错误:
配置对象无效。已使用与API架构不匹配的配置对象初始化了Webpack。-Configuration.entry‘’main‘不应包含项目’-‘两次。->非空字符串的非空数组
我已经配置好了,并尝试了
下面是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')}
)
]
}


发布于 2021-12-18 03:26:10
我在start命令中添加了"--live-reload false“来解决这个问题。
“脚本”:{
"ng":"ng","start":"ng serve --live-reload false"," build ":"ng build","watch":"ng build --watch --配置开发“,"test":"ng test","build:single-spa: mf-test2 ":"ng build mf-test2 --prod",“服务:单spa: mf-test2”:"ng s--项目mf-test2--禁用主机检查--端口NaN --实时重新加载错误“},
发布于 2019-08-30 18:50:44
我想这能行得通
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')}
)
]
}发布于 2019-09-03 17:00:19
在package.json中更改脚本启动命令,如下所示使其工作,
"start": "webpack-dev-server --config webpack.config.js --port 3000",https://stackoverflow.com/questions/57724981
复制相似问题