• 请不要在回答技术问题时复制粘贴 AI 生成的内容
123s
V2EX  ›  程序员

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

  •  
  •   123s · Jan 19, 2016 · 4303 views
    This topic created in 3856 days ago, the information mentioned may be changed or developed.
    目前用 html-webpack-plugin ,所有东西都打包在同一个目录了,项目中的模板(html)和静态文件是分开不同目录的。
    5 replies    2016-01-22 10:56:08 +08:00
    shiye515
        1
    shiye515  
       Jan 19, 2016 via Android
    你看下 output 中的 filename 和 chunkfilename 的文档 ,给静态资源加 hash 这个功能自带的
    123s
        2
    123s  
    OP
       Jan 22, 2016
    @shiye515 你直接改 filename ,你不得人工去改一下 Html 引用。
    shiye515
        3
    shiye515  
       Jan 22, 2016
    HtmlWebpackPlugin inject: true,
    123s
        4
    123s  
    OP
       Jan 22, 2016
    @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  
       Jan 22, 2016
    @123s 如果你页面多到写配置都感觉麻烦的时候,我感觉就没必要用 webpack 了,试试 fis 吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:04 · PVG 04:04 · LAX 13:04 · JFK 16:04
    ♥ Do have faith in what you're doing.