Internet explorer 无法解决网页包中的IE 8预期标识符问题

Internet explorer 无法解决网页包中的IE 8预期标识符问题,internet-explorer,webpack,babeljs,Internet Explorer,Webpack,Babeljs,我在我的项目中使用webpack,项目必须在IE8企业模式下运行 transform-es3-member-expression-literals transform-es3-property-literals 该答复建议: 我试过babel polyfill,也试过transform runtime,但似乎什么都没用 我的makewebpackconfig文件如下所示: var path = require('path'); var webpack = require('webpack');

我在我的项目中使用webpack,项目必须在IE8企业模式下运行

transform-es3-member-expression-literals transform-es3-property-literals

该答复建议:

我试过babel polyfill,也试过transform runtime,但似乎什么都没用

我的makewebpackconfig文件如下所示:

var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var AppCachePlugin = require('appcache-webpack-plugin');
var appConfigObj = require('./server.js');
var appPort = 3000;
// var es3MemberExpressionLiterals = require('babel-plugin-transform-es3-member-expression-literals');
// var es3PropertyLiterals = require('babel-plugin-transform-es3-property-literals');
var es3ifyPlugin = require('es3ify-webpack-plugin');
var appHost = '11.126.44.112';

module.exports = function(options) {
    var entry, jsLoaders, plugins, cssLoaders, devtool;
    console.log('options webconfig-->', options, 'directory name', __dirname);
// If production is true
if (options.prod) {
    console.log('producaiton minifcation');
    // Entry
    entry = [
        // 'babel-polyfill',
        path.resolve(__dirname, 'js/app.js') // Start with js/app.js...
    ];

    cssLoaders = ['file-loader?name=[path][name].[ext]', 'postcss-loader'];
    // Plugins
    plugins = [ // Plugins for Webpack
        // new es3ifyPlugin(),
        new webpack.optimize.UglifyJsPlugin({
            minimize: false
        }),
        new HtmlWebpackPlugin({
            template: 'index.html', // Move the index.html file...
            minify: { // Minifying it while it is parsed using the following, self–explanatory options
                removeComments: false,
                collapseWhitespace: false,
                removeRedundantAttributes: false,
                useShortDoctype: false,
                removeEmptyAttributes: false,
                removeStyleLinkTypeAttributes: false,
                keepClosingSlash: true,
                minifyJS: false,
                minifyCSS: true,
                minifyURLs: false
            }
        })
        // new es3MemberExpressionLiterals(),
        // new es3PropertyLiterals()

    ];

    // If app is in development
} else {
    devtool = 'cheap-source-map';
    // Entry
    entry = [
        // 'babel-polyfill',
        "webpack-dev-server/client?http://localhost:3000", // Needed for hot reloading
        "webpack/hot/only-dev-server", // See above
        path.resolve(__dirname, 'js/app.js') // Start with js/app.js...
    ];
    cssLoaders = ['style-loader', 'css-loader', 'postcss-loader'];
    // Only plugin is the hot module replacement plugin
    plugins = [
        // new es3ifyPlugin(),
        new webpack.HotModuleReplacementPlugin() // Make hot loading work
        // new es3MemberExpressionLiterals(),
        // new es3PropertyLiterals()
    ]
}

return {
    devtool: devtool,
    entry: entry,
    output: { // Compile into js/build.js
        path: path.resolve(__dirname, 'build'),
        filename: "js/bundle.js"
    },
    module: {
        loaders: [{
            test: /\.js$/, // Transform all .js files required somewhere within an entry point...
            loader: 'babel', // ...with the specified loaders...
            exclude: path.join(__dirname, '/node_modules/'), // ...except for the node_modules folder.
            plugins: [
                // 'transform-runtime',
                'babel-plugin-transform-es3-property-literals',
                'babel-plugin-transform-es3-member-expression-literals',


            ]
        }, {
            test: /\.css$/, // Transform all .css files required somewhere within an entry point...
            loaders: cssLoaders // ...with PostCSS
        }, {
            test: /\.jpe?g$|\.gif$|\.png$/i,
            loader: "url-loader?limit=100000"
        }, {
            test: /\.(woff|woff2|eot|ttf|svg)$/,
            loader: 'url-loader?limit=100000'
        }, {
            test: /\.js$/,
            exclude: /node_modules/,
            loaders: ['es3ify', 'babel'],
        }]
    },
    plugins: plugins,
    postcss: function() {
        return [
            require('postcss-import')({ // Import all the css files...
                onImport: function(files) {
                        files.forEach(this.addDependency); // ...and add dependecies from the main.css files to the other css files...
                    }.bind(this) // ...so they get hot–reloaded when something changes...
            }),
            require('postcss-simple-vars')(), // ...then replace the variables...
            require('postcss-focus')(), // ...add a :focus to ever :hover...
            require('autoprefixer')({ // ...and add vendor prefixes...
                browsers: ['last 2 versions', 'IE > 8'] // ...supporting the last 2 major browser versions and IE 8 and up...
            }),
            require('postcss-reporter')({ // This plugin makes sure we get warnings in the console
                clearMessages: true
            })
        ];
    },
    target: "web", // Make web variables accessible to webpack, e.g. window
    stats: false, // Don't show stats in the console
    progress: true
}
}

我犯了一些错误,但找不到。有人能提出解决这个问题的办法吗

注意:我排除了babel loader中的节点模块。我可以在节点模块中包含的plotly.js文件中看到错误。在企业模式IE11和企业节点IE8中打开时,控制台中会看到以下错误 第xxxx行的预期标识符。 单击bundle.js中捕获语句所需的错误。
谢谢

exclude应该是一个正则表达式,但您提供的是path.join(_dirname,“/node_modules/”)可能这就是问题所在。我尝试将排除选项更改为'exclude:/node\u modules/。但它仍然在node\u modules中的plotly.js文件中的catch语句中给出了预期的标识符错误。您已经为js提供了两次加载程序。加载程序名称是'babel loader'而不是'babel'。我不知道这对其他浏览器是如何工作的,我已经删除了第二个加载程序,但它仍然在IE 8控制台中给出了这个错误。预期的标识符错误出现在nodemodules.exclude中plotly.js中的catch语句中。exclude应该是一个正则表达式,但您正在提供path.join(u dirname,“/node\u modules/”)可能这就是问题所在。我尝试将排除选项更改为'exclude:/node\u modules/。但它仍然在node\u modules中的plotly.js文件中的catch语句中给出了预期的标识符错误。您已经为js提供了两次加载程序。加载程序名称是'babel loader'而不是'babel'。我不知道这对其他浏览器是如何工作的,我已经删除了第二个加载程序,但它仍然在IE 8控制台中给出了这个错误。预期的标识符错误出现在nodemodules中plotly.js中的catch语句中。