实际的 W3C 标准规定,您的标记中不应使用 type="text/javascript"。因此,在 Webpack 中的 HtmlWebpackPlugin 内部,我使用以下设置:
new HtmlWebpackPlugin({
faviconhash: Date.now(),
template: 'index.ejs',
filename: '../index.html',
hash: true
})
我得到的是 HTML 文件,该文件很好,但它在我的脚本标记中包含不需要的类型参数:
<script type="text/javascript" src="js/app.js?15d322717ae8d7527f79"></script>
我想要的很简单:
<script src="js/app.js?15d322717ae8d7527f79"></script>
我怎样才能实现这一目标?
PS:这是来自 W3C HTML 验证器的消息:
Warning: The type attribute is unnecessary for JavaScript resources.
最佳答案
您可以打开文件 index.js
并转到第 479 行并将其删除。
https://github.com/jantimon/html-webpack-plugin/blob/master/index.js#L479
关于javascript - 如何不在Webpack中添加脚本标签类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48579988/