首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何防止Webpack进程从输入标记中移除type=“文本”

如何防止Webpack进程从输入标记中移除type=“文本”
EN

Stack Overflow用户
提问于 2016-02-03 04:13:01
回答 1查看 677关注 0票数 2

以下是我的Webpack配置的有趣摘录:

代码语言:javascript
复制
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属性吗?

EN

回答 1

Stack Overflow用户

发布于 2021-03-16 10:43:42

对于webpack 5,尝试禁用HtmlWebpackPlugin的minifier的removeRedundantAttributes

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35162942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档