【问题标题】:Systemjs builder remove file extensionSystemjs builder删除文件扩展名
【发布时间】:2016-04-04 21:41:50
【问题描述】:

我有几个 es6 模块。 add.js、sub.js 和 calc.js。 calc.js 导入 add.js 和 sub.js。

我正在使用 grunt 和 SystemJS builder 构建它们。我的 grunt 配置看起来像 -

systemjs: {
  es6: {
     options: {
        baseURL: "/",
        configFile: "config.js",
     },
     files: [{
        "src": ["src/main/calc.js"],
        "dest": "dist/calc.js"
     }]
  }
}

grunt 构建完成后,它会创建生成的 calc.js,在该文件中我可以看到:

System.register("src/main/calc.js", [.. .....

我不想要那个名称中的 .js。我想要这样的东西:

System.register("src/main/calc", [..

我该怎么办?我是否缺少一些配置?

【问题讨论】:

    标签: javascript build gruntjs systemjs


    【解决方案1】:

    这种命名行为是设计使然。 bundle() 为 SystemJs 创建一个 bundle 以在浏览器中使用,因此名称必须与 SystemJs 将尝试加载的文件名匹配。如果您想在浏览器中避免使用 SystemJ,buildStatic() 就是您要查找的内容。

    【讨论】:

      【解决方案2】:

      构建器有paths 选项。

      paths: {
        "src/main/calc": "src/main/calc.js"
      }
      

      仅供参考,有map 选项。我认为map 将是达到此目的的选择,但它对我没有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-05-12
        • 1970-01-01
        • 1970-01-01
        • 2012-06-29
        • 2019-01-03
        • 2011-11-24
        • 2011-03-14
        • 2013-01-04
        相关资源
        最近更新 更多