Heim  >  Fragen und Antworten  >  Hauptteil

javascript - webpack optput里的chunkFilename干什么用的 ?

module.exports = {
    entry: {
        index0: 'src/js/index0.js',
        index1: 'src/js/index1.js',
        index2: 'src/js/index2.js'

    },
    output: {
        path: 'dist/js',
        filename: '[name].js',
        chunkFilename: "[id].js" //  有什么用
    }
};
PHP中文网PHP中文网2748 Tage vor420

Antworte allen(3)Ich werde antworten

  • 巴扎黑

    巴扎黑2017-04-10 16:28:33

    也找了官方的很多文档,github上webpack example下看了很多,基本上都是在require.ensure去加载模块的时候才会出现,chunkFileName,个人理解是cmd和amd异步加载,而且没有给入口文件时,会生成了no-name的chunk,所以你看到的例子,chunkFileName一般都会是[id].[chunkhash].js,也就是这种chunk的命名一般都会是0.a5898fnub6.js.今天在这个网站发现了比较合理的解释,http://react-china.org/t/webpack-output-filename-output-chunkfilename/2256/2;
    希望对你有帮助!

    Antwort
    0
  • 巴扎黑

    巴扎黑2017-04-10 16:28:33

    非入口文件的命名规则

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-10 16:28:33

    一个小的提醒:
    刚刚试了下,
    如果require.ensure中注入的这个文件已经在其他地方引入了的话,
    可能就不会单独生成文件了

    Antwort
    0
  • StornierenAntwort