Angular 2 + Typescript compiler copy html and css files

后端 未结 7 1195
清酒与你
清酒与你 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:22

    No, the TypeScript compiler is just for *.ts file.

    You have to copy other files like *.html and *.css using a copy method like cp shell command inside a npm script or grunt-contrib-copy for example.

    Example using npm script:

    "scripts": {
      "html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;"
    }
    

    Just run npm run html in the shell.

    Example using grunt:

    copy: {
          html: {
              src: ['**/*.html'],
              dest: 'dist',
              cwd: 'app',
              expand: true,
          }
    }
    

提交回复
热议问题