Is there a way how to set tsconfig.json
environmentally specific such as tsconfig.prod.json
and tsconfig.dev.json
?
I want to have sourceMap
and comments
on dev environment, but I want to remove these on production.
You can use extends
for this.
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#configuration-inheritance-with-extends
Example: tsconfig.prod.json
{
"extends": "./tsconfig",
"compilerOptions": {
"sourceMap": "false"
}
}
If you use webpack
and ts-loader
you can then set it like this:
https://github.com/TypeStrong/ts-loader#configfile-string-defaulttsconfigjson
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{
test: /\.tsx?$/,
use: [
{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['react-hot-loader/babel'],
},
},
{
loader: 'ts-loader',// (or awesome-typescript-loader)
options: {
configFile: 'tsconfig.prod.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