美文网首页
Babel转ES5后IE8下的兼容性问题解决方案

Babel转ES5后IE8下的兼容性问题解决方案

作者: 白水螺丝 | 来源:发表于2017-03-31 08:58 被阅读1802次

    1、webpack配置文件,增加插件transform-es3-property-literals和transform-es3-member-expression-literals

    const webpackdevConfig = {
      entry: entry,
      output: {
        path: path.join(__dirname, 'dist/js'),
        filename: '[name].js',
        publicPath: '/static/'
      },
      plugins: [
        new webpack.NoErrorsPlugin(),
      ],
      module: {
        loaders: [
          {
            test: /\.js$/, loader: ['babel'], include: [path.join(new_dir, 'src')],
            query:{
              "presets": ["es2015", "stage-0"],
              "plugins" : [
                "transform-es3-property-literals",
                "transform-es3-member-expression-literals",
              ]
            }
          },
          {test: /\.scss$/, loaders: ['style', 'css', 'sass'], include: path.join(new_dir, 'src/style')},
          {test: /\.(jpg|png)$/, loader: 'url-loader?limit=8192', include: path.join(new_dir, 'src/img')}
        ]
      }
    }
    

    2、模块导出不能使用 export default ,改为export { xxx }
    3、模块引入使用 import { } from 'xxx'
    4、引入es5-shim.min.js和es5-sham.min.js

    相关文章

      网友评论

          本文标题:Babel转ES5后IE8下的兼容性问题解决方案

          本文链接:https://www.haomeiwen.com/subject/ddpmottx.html