【问题标题】:How to use ng build to generate ts, map and js files into the same folder?如何使用ng build生成ts、map和js文件到同一个文件夹?
【发布时间】:2017-03-24 03:27:06
【问题描述】:

我使用“ng new Sample”来生成一个新的 Angular2 文件夹。 Angular 的版本是 2.1.0。 文件夹结构为:

angular-cli.json  
karma.conf.js      
package.json       
protractor.conf.js 
README.md          
tslint.json        
node_modules       
e2e                
src     
   ----app     
     ------app.component.css    
     ------app.component.html   
     ------app.component.spec.ts     
     ------app.component.ts     
     ------app.module.ts        
     ------index.ts             

tsconfig.json 文件:

    {
      "compilerOptions": {
        "outDir": "${workspaceRoot}/debug",
        "sourceMap": true,
        //"inlineSources": true,
        "rootDir": "${workspaceRoot}",
        "target": "es5",
        "typeRoots": [
          "../node_modules/@types"
        ]
      }
    }

然后我运行“ng build”,下面的文件被输出到“dist”文件夹。 但实际上,我并没有在任何配置文件中设置“dist”文件夹。

              Asset       Size  Chunks             Chunk Names
      main.bundle.js    2.75 MB    0, 2  [emitted]  main
    styles.bundle.js    10.2 kB    1, 2  [emitted]  styles
           inline.js    5.53 kB       2  [emitted]  inline
            main.map     2.8 MB    0, 2  [emitted]  main
          styles.map      14 kB    1, 2  [emitted]  styles
          inline.map    5.59 kB       2  [emitted]  inline
          index.html  474 bytes          [emitted]

我的问题是如何在不使用 gulp 的情况下使用 ng build 将 ts、map 和 js 文件分别输出到一个文件夹中?什么是 inline.js?为什么文件会输出到 dist 文件夹?

【问题讨论】:

    标签: angular angular-cli


    【解决方案1】:

    如果你检查你的文件夹,你应该有一个名为:

    angular-cli.json
    

    打开此文件并转到:

      "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"
          ],
    

    更改 outDir 文件夹的路径。

    【讨论】:

      猜你喜欢
      • 2020-12-15
      • 2023-01-13
      • 2019-04-25
      • 2018-07-02
      • 2019-05-21
      • 1970-01-01
      • 2019-12-19
      • 2019-12-03
      • 2017-12-11
      相关资源
      最近更新 更多