webpack 你们用哪个插件来生成 hash 的静态资源

2016-01-19 12:35:45 +08:00
 123s
目前用 html-webpack-plugin ,所有东西都打包在同一个目录了,项目中的模板(html)和静态文件是分开不同目录的。
3859 次点击
所在节点    程序员
5 条回复
shiye515
2016-01-19 14:44:29 +08:00
你看下 output 中的 filename 和 chunkfilename 的文档 ,给静态资源加 hash 这个功能自带的
123s
2016-01-22 09:27:41 +08:00
@shiye515 你直接改 filename ,你不得人工去改一下 Html 引用。
shiye515
2016-01-22 09:56:14 +08:00
HtmlWebpackPlugin inject: true,
123s
2016-01-22 10:32:08 +08:00
@shiye515 用过这个,如果是传统页面,不是要写 N 个配置?
Generating Multiple HTML Files
To generate more than one HTML file, declare the plugin more than once in your plugins array:

{
entry: 'index.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin(), // Generates default index.html
new HtmlWebpackPlugin({ // Also generate a test.html
filename: 'test.html',
template: 'src/assets/test.html'
})
]
}
shiye515
2016-01-22 10:56:08 +08:00
@123s 如果你页面多到写配置都感觉麻烦的时候,我感觉就没必要用 webpack 了,试试 fis 吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/251798

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX