In my webpack.config.js i am importing several JS objects for the configuration from other files. These object are composed using spread operator. Ex. in build.js
const otherObj = { a:[], b: [] }
const conf = {
prop1: [],
...otherObj
}
Then i want to use these objects in the webpack.config.js in this way:
const { prop1, a, b } = require('./build.js');
module.exports = {
entry: { prop1, a, b },
rules: [
{
test: jsRegex,
exclude: /node_modules/,
use: ["babel-loader"]
},
]
}
When i launch the build script i get a SyntaxError:
...otherObj,
^^^
SyntaxError: Unexpected token ...
NOTE: Here follows the .babelrc
{
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/syntax-object-rest-spread"
]
}