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.json looks like:
{ "compilerOptions": { "module": "commonjs", "target": "es6", "noImplicitAny": false, "sourceMap": true, "outDir": "../../dist", "types": [ ] }, "include": [ "file1.ts", "config.json" ], "exclude": [ "../../node_modules" ] }
I would like the config.json
to end up in my ../../dist directory, but this isn't happening. Is there no concept of a content file for TypeScript?
The presence of a tsconfig. json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig. json file specifies the root files and the compiler options required to compile the project.
ts-node automatically finds and loads tsconfig. json . Most ts-node options can be specified in a "ts-node" object using their programmatic, camelCase names. We recommend this because it works even when you cannot pass CLI flags, such as node --require ts-node/register and when using shebangs.
Correct Answer : Option (C) : This file is used to give the options about TypeScript used for the Angular JS project.
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
I was having the same problem and the solution for this was to add:
"source-path/**/*.json"
keeping into "includes" array:
"source-path/**/*"
Example:
{ "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "es2017", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "resolveJsonModule": true, "incremental": true }, "include":[ "src/**/*", "src/**/*.json", ], }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With