使用babel-loader但Object.assign不是函数 [英] use babel-loader but Object.assign is not a function

查看:160
本文介绍了使用babel-loader但Object.assign不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?optional[]=runtime'}

我安装了babel-runtime

I installed babel-runtime

我将webpack与上面的babel-loader配置一起使用,但是get Object.assign不起作用.我该如何解决?

I use webpack with babel-loader config above, but get Object.assign is not function. How do I fix it?

推荐答案

您将需要安装babel-runtime.

You will need to install babel-runtime.

npm install babel-runtime --save-dev

然后,您可以在Webpack配置中将以下内容用作加载程序-

Then you can use the following as a loader in your webpack config -

{
  test: /\.js?$/,
  exclude: /node_modules/,
  loaders: ['babel?optional=runtime']
}

{
  test: /\.js?$/,
  exclude: /node_modules/,
  loader: 'babel-loader?optional=runtime'
}

这篇关于使用babel-loader但Object.assign不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆