robertwt7's avatar

How to setup babel to read package.json in mix?

Hi Guys,

I"m new to react and front end stuff, so today i learned stuff about

@babel/plugin-proposal-class-properties in babel plugin. I learned that in babel you can put the presets and plugins together in package.json under babel: ... tag.

However when I put them there it is not loaded by laravel mix when I run them , do i need to change any config of webpack or something?

I manage to do it after I created .babelrc with this:

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ],
    "plugins": [
        [
            "@babel/plugin-proposal-class-properties",
            {
                "loose": true
            }
        ]
    ]
}

Previously when I try to put that in package.json it does not get loaded. Already checked it through console.log(Config.babel());

Any help would be appreciated, I don't want to have multiple configs for my js files so I want them as one in package.json

Thanks

0 likes
1 reply

Please or to participate in this conversation.