Is there any way to have the TypeScript compiler also copy content files that don\'t have a ts or tsx extension to the output directory?
For example, my tsconfig.jso
No, the tsc
command's job is only to compile .ts files. It doesn't have the capabilities to do build-related tasks that a build system like gulp, grunt or webpack would handle.
For more information, see this similar question: Angular 2 + Typescript compiler copy html and css files
One workaround is to make the json file a normal js file, require/import it normally, and add "allowJs" : true
to "compilerOptions" in tsconfig.json.
This can be achieved by setting "resolveJsonModule": true
in the compiler options and adding "source-path/**/*.json"
to the include
array in the tsconfig.json