最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable babel strict mode from webpack.config.js - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question asked Jul 29, 2016 at 17:16 stackoverflowerstackoverflower 4,07311 gold badges51 silver badges75 bronze badges 2
  • This is babel 6, so black list doesn't work anymore – stackoverflower Commented Jul 29, 2016 at 17:17
  • How about using this preset? – robertklep Commented Jul 29, 2016 at 18:19
Add a ment  | 

1 Answer 1

Reset to default 5

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/
            },
        ]
    },
};
发布评论

评论列表(0)

  1. 暂无评论