webpack打包多入口文件

Javascript piniu 1391浏览 0评论
//多入口
  entry: {
    home: './src/home',
    other: './src/other'
  },
output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist')
  },
plugins: [
  new htmlWebpackPlugin({
      template: './index.html',
      filename: 'home.html',
      chunks: ['home']
    }),
  new htmlWebpackPlugin({
      template: './index.html',
      filename: 'other.html',
      chunks: ['other']
    }),
]

使用[name]表示动态的名字
如果需要每次打包产生新的文件,并且指定生成8位hash码,可以把output里的filename这样写[name].[:8].js

本文来自互联网分享,作者:weixin_42182143,原文链接:https://blog.csdn.net/weixin_42182143/article/details/103779658
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • *昵称:
  • *邮箱: