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.
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'
},
},
],
},