Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable babel stage-0 in webpack config file

I used the below-mentioned command:

npm install --save-dev babel-preset-stage-0

Now I added it in webpack.config.js file as shown below:

module.exports = {
    entry: './app/app.jsx',
    output: {
        path: __dirname,
        filename: './public/bundle.js'
    },
    resolve: {
        root: __dirname,
        alias: {

        },
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-0']
                },
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/
            }
        ]
    }
};

But Now when I run webpack command it shows some error. Please check error:

Error image:

enter image description here

like image 614
Nitin Bisht Avatar asked Nov 23 '25 15:11

Nitin Bisht


1 Answers

If you are not using a .babelrc file, add babelrc: false like so:

module: {
    loaders: [
        {
            loader: 'babel-loader',
            babelrc: false, // <--- Add this
            query: {
                presets: ['react', 'es2015', 'stage-0']
            },
            test: /\.jsx?$/,
            exclude: /(node_modules|bower_components)/
        }
    ]
}

I recommend using the create-react-app CLI if you don't want to deal with the headache of setting up a development environment boilerplate. I just started using it and it is great!

like image 161
Funk Soul Ninja Avatar answered Nov 25 '25 10:11

Funk Soul Ninja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!