Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript babel Transfile to es5不适用于节点\ U模块_Javascript_Webpack_Babel Loader - Fatal编程技术网

Javascript babel Transfile to es5不适用于节点\ U模块

Javascript babel Transfile to es5不适用于节点\ U模块,javascript,webpack,babel-loader,Javascript,Webpack,Babel Loader,我试图在IE11中运行我当前的项目,但是它给了我一个错误:在Projtual.js(谷歌的材料设计类的一部分)中说 Script PT1002:语法错误< /代码>。有问题的行是导出默认MDCFoundation。现在,从我得到的红色问题是,这是es6代码和ie11只支持es5。到现在为止,一直都还不错。现在的问题是,我似乎不知道如何让巴贝尔传输到es5。我正在使用webpack和babel,这是我的webpack.config.js: var path = require('path'); c

我试图在IE11中运行我当前的项目,但是它给了我一个错误:在Projtual.js(谷歌的材料设计类的一部分)中说<代码> Script PT1002:语法错误< /代码>。有问题的行是
导出默认MDCFoundation
。现在,从我得到的红色问题是,这是es6代码和ie11只支持es5。到现在为止,一直都还不错。现在的问题是,我似乎不知道如何让巴贝尔传输到es5。我正在使用webpack和babel,这是我的webpack.config.js:

var path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
var LiveReloadPlugin = require('webpack-livereload-plugin');
const autoprefixer = require('autoprefixer');

module.exports = {
  entry:{
    app: ['./src/app.js']
  },
  devtool: 'inline-source-map',
  externals: /^(tables.)/i,
  module: {
    rules: 
    [
      {
        test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000'
      },
      {
        test: /\.(css)$/,
        use: [
          MiniCssExtractPlugin.loader, // <---- added here
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
              plugins: () => [autoprefixer()],
            }
          }
         ],
      },
      {
        test: /\.(scss)$/,
        use: [
          MiniCssExtractPlugin.loader, // <--- added here
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
                plugins: () => [autoprefixer()],
            },
          },
          {
            loader: 'sass-loader',
            options: {
              includePaths: ['./node_modules'],
            },
          }
        ],
      },
      {
        test: /\.js$/,
        include: /src/,
        loader: 'babel-loader',
        options: {
          "presets": [
            ["env", {
              "targets": {
                "browsers": ["ie >= 11"]
              }
            }]
          ]
        }
      }
    ],
  },
  optimization: {
    splitChunks: {
      cacheGroups: {
        commons: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          chunks: 'all'
        }
      }
    }
  },
  plugins: [
    new MiniCssExtractPlugin({filename: 'style.css'}),
    new LiveReloadPlugin({}),
    new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', jquery: 'jquery' })
  ],
  resolve: {
    extensions: ['.js']
  },

  watch: true,
  watchOptions: {
    aggregateTimeout: 300,
  },
  output: {
    publicPath: './dist',
    filename: 'bundle.js',
    path: path.resolve(__dirname, './dist')
  }
};
var path=require('path');
const webpack=require('webpack');
const MiniCssExtractPlugin=require('mini-css-extract-plugin');
var LiveReloadPlugin=require('webpack-livereload-plugin');
const autoprefixer=require('autoprefixer');
module.exports={
条目:{
app:['./src/app.js']
},
devtool:“内联源映射”,
外部:/^(表)/i,
模块:{
规则:
[
{
测试:/\(png | jpg | jpeg | gif | svg)$/,使用:“url加载程序?限制=25000”
},
{
测试:/\(css)$/,
使用:[
MiniCssExtractPlugin.loader,//[autoprefixer()],
}
}
],
},
{
测试:/\(scss)$/,
使用:[
MiniCssExtractPlugin.loader,//[autoprefixer()],
},
},
{
加载器:“sass加载器”,
选项:{
IncludePath:['./节点\模块'],
},
}
],
},
{
测试:/\.js$/,,
包括:/src/,
加载器:“巴别塔加载器”,
选项:{
“预设”:[
[“环境”{
“目标”:{
“浏览器”:[“ie>=11”]
}
}]
]
}
}
],
},
优化:{
分割块:{
缓存组:{
公地:{
测试:/[\/]节点单元模块[\\/]/,,
名称:'供应商',
区块:“全部”
}
}
}
},
插件:[
新的MiniCssExtractPlugin({filename:'style.css'}),
新利弗雷洛阿普卢金({}),
新的webpack.ProvidePlugin({$:'jquery',jquery:'jquery',jquery:'jquery'})
],
决心:{
扩展:['.js']
},
手表:没错,
监视选项:{
聚合超时:300,
},
输出:{
公共路径:'./dist',
文件名:“bundle.js”,
path:path.resolve(uu dirname,'./dist')
}
};

正如你所看到的,我已经试着告诉巴贝尔为ie11传输,但它仍然给我同样的错误。

foundation.js的内容是什么?您已将
babel加载程序
配置为仅从
src
目录传输文件,因此请确保您没有使用
src
之外的任何内容。还有,你用的是什么
webpack
babel
版本?@PavelDenisjuk Ohhhh哇,现在我觉得有点傻了。我将node_模块添加到babel的include列表中,现在它工作了(选项卡仍然不工作,但至少它没有给我任何错误)。为完整起见:您可以查看
foundation.js
的内容。我使用的是webpack的4.15.1版和babel-loader.Right的7.1.5版,因此材料的源代码位于
node_modules
(从原始问题看不清楚)。现在你知道怎么回事了,祝你好运!另外:不要将整个
node\u modules
文件夹添加到babel loader,只添加单个包,因为来自
npm
的99%包已经是ES5。