V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
123s
V2EX  ›  程序员

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

  •  
  •   123s · 2016-01-19 12:35:45 +08:00 · 3860 次点击
    这是一个创建于 3024 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前用 html-webpack-plugin ,所有东西都打包在同一个目录了,项目中的模板(html)和静态文件是分开不同目录的。
    5 条回复    2016-01-22 10:56:08 +08:00
    shiye515
        1
    shiye515  
       2016-01-19 14:44:29 +08:00 via Android
    你看下 output 中的 filename 和 chunkfilename 的文档 ,给静态资源加 hash 这个功能自带的
    123s
        2
    123s  
    OP
       2016-01-22 09:27:41 +08:00
    @shiye515 你直接改 filename ,你不得人工去改一下 Html 引用。
    shiye515
        3
    shiye515  
       2016-01-22 09:56:14 +08:00
    HtmlWebpackPlugin inject: true,
    123s
        4
    123s  
    OP
       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
        5
    shiye515  
       2016-01-22 10:56:08 +08:00
    @123s 如果你页面多到写配置都感觉麻烦的时候,我感觉就没必要用 webpack 了,试试 fis 吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   853 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:17 · PVG 04:17 · LAX 13:17 · JFK 16:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.