【问题标题】:Aurelia bundling and transpilingAurelia 捆绑和转译
【发布时间】:2016-03-16 08:59:06
【问题描述】:

我目前正在尝试将 Aurelia 应用程序捆绑用于“生产”。我尝试使用$ aurelia bundle,或者现在使用 gulp;这是完全一样的。但我会一直拥有

<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
  System.import('aurelia-bootstrapper');
</script>

在我的index.html 中,这意味着我必须在我的服务器上上传 jspm 包(好吧,也许不是全部),并且 Babel 的 1.9mb browser.js 文件将被加载到浏览器中,然后它才会转译.可能会很长。

有什么方法可以得到一个捆绑转译缩小的文件?是否有意义? 非常感谢!

这是我的配置(在我的 gulpfile.js 中)

  bundles: {
    "src/dist/app-bundle": {
      includes: [
        '*',
        'aurelia-bootstrapper',
        'aurelia-fetch-client',
        'aurelia-router',
        'aurelia-templating-binding',
        'aurelia-templating-resources',
        'aurelia-templating-router',
        'aurelia-loader-default',
        'aurelia-history-browser',
        'aurelia-auth'
      ],
      options: {
        inject: true,
        minify: true
      }
    }
  }

【问题讨论】:

  • 我不明白system.jsconfig.js 如何暗示需要browser.js 甚至任何jspm 包?为了加载system.js,你只需要jspm_packages顶层的文件(在我的系统上,目前是system.js、system-csp-production.js和system-polyfills.js)跨度>

标签: javascript ecmascript-6 babeljs aurelia


【解决方案1】:

听起来您启用了 babel 的 runtime 选项,其中 babel 仅在运行时而不是在开发时转译您的 JavaScript。

如果您在运行时将捆绑包设置为 injected 而不是转译,那么它应该会更快且占用空间更小。

【讨论】:

  • 我删除了 config.js 中的“运行时”选项,但仍加载了 browser.js 文件。我在问题中添加了我的捆绑配置。
猜你喜欢
  • 2017-01-03
  • 2019-09-01
  • 1970-01-01
  • 2017-02-15
  • 2016-10-09
  • 1970-01-01
  • 2017-03-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多