Angular 2 + Typescript compiler copy html and css files

后端 未结 7 1190
清酒与你
清酒与你 2020-12-05 07:01

In Angular2 I would have

\"outDir\": \"dist/app\"

in tsconfig.json. As a result the transpiled .js and .map files are generated in /di

7条回答
  •  无人及你
    2020-12-05 07:10

    For an OS independent solution, use copyfiles

    npm install copyfiles --save-dev
    

    Then add a script to package.json

    "scripts": {
      "html": "copyfiles -u 1 app/**/*.html app/**/*.css dist/"
    }
    

    Now npm run html should copy all css and html files from the app/ folder to dist/app/

    EDIT: I'd like to amend my answer to point out angular-cli. This command line tooling utility is supported by the angular team and makes bundling a breeze (ng build --prod), among other things.

提交回复
热议问题