【问题标题】:how to change the path of Angular app scripts on production build?如何在生产构建中更改 Angular 应用脚本的路径?
【发布时间】:2019-08-03 17:32:36
【问题描述】:

如何放置我所有的主要 Angular 脚本和 css 文件,例如:

main.[hash].js、scripts.[hash].js、styles.[hash].css、runtime.[hash].js、polyfills.[hash].js

在每个构建项目上自动在另一个文件夹中(如下图所示)。我只想要我的 dist 文件夹中的两个文件夹,第一个是 assets 文件夹,第二个是 ng-main,其中包含应用程序脚本和 css,最后一个是 index.html 文件。

【问题讨论】:

    标签: angular angular6 angular-cli angular-cli-v6


    【解决方案1】:

    我相信这不是 angular 的事情,并且 angular 也没有看到任何好处。见This issue

    有一些解决方案,即创建一个脚本来运行后期构建。 请参阅This question 了解可能的解决方案。

    或者.....您也可以将其添加到您的 npm 脚本中:

    {
      "name": "app",
      "version": "0.0.0",
      "scripts": {
      "ng": "ng",
      "build": "ng build && bash mkdir dist/App/ng-main && bash find dist/App -type f ! \( -iname '*.html' \) -exec `echo mv {} ./dist/App/ng-main/` \;",
      ...
    }
    

    然后运行

    npm run build
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-17
      • 2021-06-13
      • 2018-08-03
      • 2020-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      相关资源
      最近更新 更多