htmlWebpackPlugin不';不添加基标记
我正在尝试使用htmlwebpack插件创建一个输出html。下面是我的配置。标题被添加到HTML中,但基本标记没有添加。文档中说插件有一个基本参数,该参数采用字符串值。我是通过与文档中的示例进行类比来完成的,但是标记没有出现在输出文件中。我做错了什么?我找到了一个解决方法,添加了一个模板,在这里我设置了base标记htmlWebpackPlugin不';不添加基标记,webpack,html-webpack-plugin,Webpack,Html Webpack Plugin,我正在尝试使用htmlwebpack插件创建一个输出html。下面是我的配置。标题被添加到HTML中,但基本标记没有添加。文档中说插件有一个基本参数,该参数采用字符串值。我是通过与文档中的示例进行类比来完成的,但是标记没有出现在输出文件中。我做错了什么?我找到了一个解决方法,添加了一个模板,在这里我设置了base标记 template: 'src/index.html', 但是我想在没有它的情况下解决这个问题 const path = require('path'); const HtmlWe
template: 'src/index.html',
但是我想在没有它的情况下解决这个问题
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
mode: 'production',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.(js)$/, use: 'babel-loader' },
{ test: /\.(jsx)$/, exclude: /node_modules/, use: 'babel-loader' },
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
'url-loader?limit=10000',
'img-loader'
]
}
]
},
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
new HtmlWebpackPlugin({
title: 'App',
base: '/',
filename: 'index.html',
isProduction: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
})]
};
我也在寻找同样的,我发现“这个功能只包括在当前的测试版html网页插件4.x中”,我忘了,我也找到了。到今天为止,它工作正常。我正在寻找相同的,我发现“这个功能只包括在当前的测试版html网页插件4.x”我忘了,我还找到了。从今天起,它工作得很好。