"loose": true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled
I am using plugin-proposal-class-propterties
and it works, here is my JSON configuration file .babelrc
{ "presets": ["@babel/preset-env"], "plugins": [ [ "@babel/plugin-proposal-class-properties", {"loose": true} ] ]}
Try making a file babel.config.js
and using module.exports
to export the configuration. I also believe you don't require the loose
option:
babel.config.js
:
module.exports = { presets: ["@babel/preset-env", "@babel/preset-react"], plugins: ["@babel/plugin-proposal-class-propterties"]};
you must install
npm install @babel/core @babel/plugin-proposal-class-properties@babel/preset-env @babel/preset-react babel-loader
and
change entry and output
const path = require('path') module.exports = { entry: path.resolve(__dirname,'src', 'app.js'), output: { path: path.resolve(__dirname, "public","dist",'javascript'), filename: 'bundle.js' }, module: { rules: [ { test: /\.(jsx|js)$/, exclude: /node_modules/, use: [{ loader: 'babel-loader', options: { presets: [ ['@babel/preset-env', { "targets": "defaults" }], '@babel/preset-react' ], plugins: [ "@babel/plugin-proposal-class-properties" ] } }] } ] }}