以下是我的Webpack配置的有趣摘录:
module: {
loaders: [
{
test: /\.js$/, exclude: /node_modules/,
loader: 'ng-annotate!babel?presets[]=es2015'
},
{
test: /\.scss$/, loader: ExtractTextPlugin.extract("style", "css!sass")
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, loader: "file-loader?name=fonts/[name].[ext]"
},
{
test: /\.(jpe?g|png|gif|svg)$/i, loader: "file-loader?name=images/[name].[ext]?[hash]"
},
{
test: /\.tpl\.html$/, exclude: /node_modules/, loader: "html-loader"
}
]
}当我运行webpack -p时,我抱怨从一些超文本标记语言输入中删除了type="text"。
我有一些样式的一些组件关于type="text"的存在。
有没有办法阻止Webpack的制作过程(丑化?)要删除此HTML属性吗?
发布于 2021-03-16 10:43:42
对于webpack 5,尝试禁用HtmlWebpackPlugin的minifier的removeRedundantAttributes:
new HtmlWebpackPlugin({
template: `./src/index.html`,
filename: `index.html`,
minify: {
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true,
removeRedundantAttributes: false, // do not remove type="text"
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
}
});文档:https://github.com/jantimon/html-webpack-plugin#minification
https://stackoverflow.com/questions/35162942
复制相似问题