有時候用webpack打包,引入的require檔案中有報錯,是由於嚴格模式引起的。es6自動打包成es5會加上嚴格模式。如何取消掉,直接在webpack配置檔案中設定:

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/
            },
        ]
    },
};