2015-08-20 25 views
1

{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?optional[]=runtime'}使用巴貝爾裝載機但Object.assign不是

我安裝了巴貝爾的運行時

我用的WebPack與巴貝爾裝載機配置上面,但得到Object.assign不是功能的功能。我如何解決它?

回答

3

您需要安裝通天塔運行時。

npm install babel-runtime --save-dev 

然後你可以用以下的裝載機在你的WebPack配置 -

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

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

如果排除node_modules,不是transpile代碼爲使用對象庫。分配? –

0

它應該工作,如果你只使用babel作爲裝載機:

{ test: /\.js$/, exclude: /node_modules/, loader: 'babel'}