webpack5多页面打包的问题?

{
      entry: {
        index: './src/index.js',
        about: './src/about.js',
      },
        plugins: [
          new HtmlWebpackPlugin(
            {
              url: './',
              title: 'My Webpack',
              filename: 'index.html',
              template: './src/index.html',
            },
          ),
          new HtmlWebpackPlugin(
            {
              url: './',
              title: 'My Webpack',
              filename: 'about.html',
              template: './src/about.html',
            },
          ),
          ...
        ],
}

上面的webpack配置,打包出来的index.html/index.js和about.html/about.js

但是index.html引用了about.js和index.js

about.html也引用了about.js和index.js

要怎么样才能各自页面引用各自的js呢

阅读 1.5k
2 个回答

inject设置成false,在html里去设置各自引用的js

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题