I have the following webpack loader configuration that works great, but I want to move the babel options to a .babelrc file. When I cut/paste (and update the syntax) into the .babelrc file, it no longer transpiles the code and throws errors that it can find loaders. The rc file is in root, and if I remove the plugins the alias fails so I'm confident it's finding the file. Using webpack 4 and babel-loader 8.
Webpack (which works):
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
'corejs': '3.35',
'useBuiltIns': 'entry'
}]
],
plugins: [
['babel-plugin-module-resolver', {
'alias': {
'~': './src'
}
}],
'@babel/plugin-proposal-function-bind'
],
comments: false
}
},
exclude: {
and: [/node_modules/],
not: [
/ol/,
]
}
},
.babelrc (doesn't work)
"presets": [
["@babel/preset-env", {
"corejs": "3.35",
"useBuiltIns": "entry"
}]
],
"plugins": [
["babel-plugin-module-resolver", {
"alias": {
"~": "./src"
}
}],
"@babel/plugin-proposal-function-bind"
],
"comments": false
}