Separate Angular2 TypeScript files and JavaScript files into different folders, maybe 'dist‘

后端 未结 16 2316
清酒与你
清酒与你 2020-11-28 19:52

I am using the 5 min quickstart from angular.io website, which contain a file structure like this:

angular2-quickstart
 app
   app.component.ts
   boot.ts
 i         


        
16条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 20:35

    I may be also late but I did this.

    First do what raheel shan said.

    Then create the dist folder.

    After creating the folder go to the file tsconfig.json and add this:

    "outDir": "dist"
    

    The resulting tsconfig.json

    {
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "outDir": "dist"
      },
      "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
      ]
    }
    

    If you now run npm start and save a file you should see all the compiled .js and .map.js in the dist folder.

提交回复
热议问题