【问题标题】:Where else can I declare included scripts in angular-cli?我还能在哪里声明 angular-cli 中包含的脚本?
【发布时间】:2017-07-28 11:58:58
【问题描述】:

angular-cli.json 我有:

"polyfills": "polyfills.ts"
"scripts": ["script1.ts"]

我想专门为ie11 添加另一个polyfill 脚本,然后我可以在最终构建时将其包装在条件注释中,以减少其他浏览器的加载时间。

我将如何包含这样一个脚本,以便它在运行时与项目的其余部分一起编译,但不会捆绑到上述任何一个中?

【问题讨论】:

    标签: angular angular-cli


    【解决方案1】:

    如果您希望 cli 在单独的包中输出脚本,您可以使用global-scripts,例如:

    "scripts": [
        { "input": "../node_modules/module-name", "output": "module-custom-name", "lazy": true}
    ],
    

    当您指定"lazy": true 时,cli 将创建一个单独的文件,其中仅包含您想要有条件地加载的模块。

    【讨论】:

    • 这看起来很有希望,谢谢!我会调查的。
    • 但是如果我不使用 cli 怎么办,我在 mvc5 应用程序 (Visual Studio 2015) 中使用 angular,那么如何添加 polyfills
    • @FaresAyyad 为什么不使用 cli?否则,您必须在自定义构建中包含脚本。
    • 如何在vs2015中使用angular cli,我曾经用visual studio构建项目!!?我的观点是如何在 Visual Studio 中添加 polyfill?
    • @FaresAyyad 您必须对此进行研究或提出相关问题。
    猜你喜欢
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    • 2017-07-12
    • 2011-07-22
    相关资源
    最近更新 更多