{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
const BabelConf = preset => {
const opts = {
presets: [
'@babel/preset-env'
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
if (preset) opts.presets.push(preset)
return opts
}
...
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules/',
options: BabelConf()
},
{
test: /\.ts$/,
loader: 'babel-loader',
exclude: '/node_modules/',
options: BabelConf('@babel/preset-typescript')
},
]
}