I have 2 tsconfigs, one for my dev build and one for my prod build.
I choose the tsconfig with the -p
flag :
tsc -p dev.tsconfig.json
Ts-loader is looking for a tsconfig.json file. How can I specify another filename with the ts-loader?
module.exports = {
entry : __dirname + "/src/app/main.ts",
output : {
path : __dirname + "/dist",
filename : "bundle.js"
},
resolve : {
extensions : ["", ".webpack.js", ".web.js", ".js", ".ts"]
},
module: {
loaders: [
{ test: /\.ts?$/, loader: "ts" }
]
}
};
In Webpack 4 you need to specify the options into a use
object:
use: [{
loader: 'ts-loader',
options: {
configFile: "tsconfig.webpack.json"
}
}]
Complete Webpack config:
var path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src') + '/index.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'your-library-name.js',
},
module: {
rules: [
{
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options: {
configFile: "tsconfig.webpack.json"
}
}],
exclude: /node_modules/,
}
]
},
mode: 'development',
resolve: {
extensions: ['.js', '.ts']
},
devtool: false
};