Angular 2 + Typescript compiler copy html and css files
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.
This approach is provided by Microsoft:-
https://github.com/Microsoft/TypeScript-Node-Starter
Check out the file "copyStaticAssets".
None of the solutions above worked for me, so I hope this helps someone like me.
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,
}
}