Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable babel strict mode from webpack.config.js

So far I haven't found any COMPLETE example on this. There are answers talking about babel-plugin-transform-strict-mode, but no code about how it should be configured.

Can anybody provide a simple working code snippet for how to configure the babel loader to disable strict mode? Thanks

like image 422
stackoverflower Avatar asked Oct 14 '25 16:10

stackoverflower


1 Answers

I'll add a simple config below.

Also note that if you use ES6 syntax (like import instead of require), webpack will automatically add "use strict" as all ES6 modules are expected to be strict mode code.

var config = {
    entry: {
        home: buildBundle( 'home' ),
    },
    output: {
        path: BUILD_DIR,
        filename: '[name]-bundle.js'
    },
    module : {
        loaders : [
            {
                test: /\.js?/,
                include: APP_DIR,
                use: {
                    loader: 'babel-loader',
                    options: {
                        "presets": [
                            ['es2015', {modules: false}]
                        ],
                    }
                },
                exclude: /node_modules/
            },
        ]
    },
};
like image 198
Andrew Rockwell Avatar answered Oct 17 '25 05:10

Andrew Rockwell