gpt4 book ai didi

javascript - 多个 Assets 向同一文件名 index.html 发出不同的内容

转载 作者:行者123 更新时间:2023-12-05 06:51:25 25 4
gpt4 key购买 nike

我的 webpack 配置给出了以下错误 Multiple assets emit different content to the same filename index.html

当我删除 htmlWebpackPlugin 时它可以工作,但我不会显示任何 html。我正在使用 Vue.js,我的配置如下所示:

const path = require('path')

const { VueLoaderPlugin } = require('vue-loader')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

module.exports = (env, argv) => ({
mode: argv && argv.mode || 'development',
devtool: (argv && argv.mode || 'development') === 'production' ? 'source-map' : 'eval',

entry: './src/app.js',

output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},

node: false,

module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
exclude: /\.module\.css$/
}
]
},

resolve: {
extensions: [
'.js',
'.vue',
'.json'
],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve(__dirname, 'src')
}
},

plugins: [
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: ['dist']
}),
new VueLoaderPlugin(),
new HtmlWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, 'dist'),
toType: 'dir'
}]
})
],

devServer: {
compress: true,
host: 'localhost',
https: true,
open: true,
overlay: true,
port: 9000
}
});

我的文件结构是这样的

enter image description here

我看过Conflict: Multiple assets emit to the same filename但没有适合我的解决方案,还有其他选择吗?

最佳答案

会不会是Vue loader also emits index.html?

尝试:

new HtmlWebpackPlugin({
template: './index.html',
filename: 'anotherFileName.html',
}),

关于javascript - 多个 Assets 向同一文件名 index.html 发出不同的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66170274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com