1. 程式人生 > >webpack引入第三方js去除嚴格模式的幾種方法

webpack引入第三方js去除嚴格模式的幾種方法

1. babel5

babel: {
    options: {
        blacklist: ["useStrict"],
        // ...
    },
    // ...
}

2. babel6

略過模組:
        {
  presets: [
    ["es2015", { "modules": false }]
  ]
}

略過某個檔案:

{
  "presets": ["es2015"],
  "ignore": [
    "./src/js/directive/datePicker.js"
  ]
}

3. babel-plugin-transform-remove-strict-mode該外掛通過npm安裝在.babelrc中配置

plugins:["transform-remove-strict-mode"]