When working with Angular2, I usually set the following configuration in my tsconfig.json file:
"outDir": "dist/app"
This setup allows for the transpiled .js and .map files to be generated within the /dist/app/ folder or its subfolders. This typically works without any issues.
In my component.ts files, I often reference HTML and CSS files like this:
@Component({
selector: 'my-app',
templateUrl: 'app/appshell/app.component.html',
styleUrls: ['app/appshell/app.component.css'],
......
}
Is there a way to configure the compiler to also copy these referenced HTML and CSS files for the entire project? If so, how would I adjust my tsconfig.json?
I have reviewed the compiler options listed here https://www.typescriptlang.org/docs/handbook/compiler-options.html, but did not find any information regarding copying html/css files.
Update: My project's folder structure is as follows:
Root
|--app // for ts
|--dist/app // for js
tsconfig.json contains:
"outDir": "dist/app"
And package.json includes:
{
"name": "TestApp",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;",
......
}
However, despite this setup, the HTML files are not being copied over. Strangely, no error messages are displayed either.
Another Update:
If you're using a Linux OS, Bernardo's solution may work fine. However, for those on Windows OS, the following script should do the trick:
"scripts": {
"html": "XCOPY /S /y .\\app\\*.html .\\dist\\app" }