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

后端 未结 16 2281
清酒与你
清酒与你 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条回答
  •  萌比男神i
    2020-11-28 20:33

    Inspired by @Nagyl, I developed my own way and I believe it's worth to share:

    1) Install cpx

    npm install cpx
    

    2) Update bs-config.json and change baseDir from "src" to "dist"

    "baseDir":"dist"
    

    3) Update tsconfig.json and add outDir to end of compilerOptions:

    "outDir": "../dist"
    

    4) Update package.json: 4.1) add a new command to end of scripts:

    "cpx": "cpx \"src/**/*.{html,css,js,png,jpg}\" dist --watch"
    

    4.2) modify "start" line to include "cpx" command:

    "start": "concurrently \"npm run build:watch\" \"npm run cpx\" \"npm run serve\"",
    

提交回复
热议问题