Webpack Aurelia - 如何配置并非所有块都与 Aurelia 绑定?

Webpack Aurelia - How to configure that not all chunks are bundeld with Aurelia?

我正在使用 Aurelia 的 Webpack 示例 (https://aurelia.io/docs/build-systems/webpack/a-basic-example#basic-config-example) 来设置我的 Webpack 配置:

const { AureliaPlugin } = require('aurelia-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { resolve } = require('path')

module.exports = function(mode) {
  return {
    mode: mode || 'development',
    resolve: {
      extensions: ['.ts', '.js'],
      modules: [resolve(__dirname, 'src'), resolve(__dirname, 'node_modules')],
    },
    entry: {
      addOn: './dist/ContentScript/WebExtContentScriptApp.js',
      // the 'aurelia-bootstrapper' entry point is responsible for resolving your app code
      app: ['aurelia-bootstrapper'],
    },
    output: {
      filename: '[name].js',
      path: resolve(__dirname, 'dist'),
    },
    watch: mode === 'development',
    devtool: mode === 'development' ? 'inline-source-map' : 'source-map',
    devServer: {
      contentBase: './dist',
    },
    module: {
      rules: [
        { test: /\.html$/i, loader: 'html-loader' },
        { test: /\.ts$/i, loader: 'ts-loader' },
      ],
    },
    plugins: [
      // the AureliaPlugin translates Aurelia's conventions to something Webpack understands
      // and must be included in order for Webpack to work
      new AureliaPlugin(),
      new HtmlWebpackPlugin({
        template: 'index.ejs',
        chunks: ['app'],
        metadata: { dev: mode !== 'production' },
      }),
    ],
  }
}

我添加了另一个 entry 配置 addOn。 运行 webpack 现在会按预期生成两个区块:appaddOn。唯一出乎意料(不需要)的是,这两个块都与 aurelia 模块捆绑在一起。只有 app 应与 aurelia 个模块捆绑在一起。

如何确定哪个块应与 aurelia 模块捆绑?

要使用的 entry 可以使用对象文字传递给 AureliaPlugin 的构造函数:

new AureliaPlugin({
  entry: 'app',
})

entry 选项和其他选项可在此处找到:https://github.com/aurelia/webpack-plugin/wiki/AureliaPlugin-options