首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Webpack Aurelia -如何配置并非所有块都与Aurelia绑定?

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

Stack Overflow用户
提问于 2020-10-03 20:25:28
回答 1查看 18关注 0票数 0

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

代码语言:javascript
复制
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模块。aurelia模块只能与app捆绑在一起。

如何确定哪个块应该与aurelia模块捆绑在一起?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-04 03:50:46

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

代码语言:javascript
复制
new AureliaPlugin({
  entry: 'app',
})

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64184236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档