8
一直試圖使用反應旋NPM模塊,但是當我嘗試建立與一的WebPack bundle.js,我收到以下錯誤:的WebPack與反應模塊給人意外的標記
Module parse failed: /Users/nir/browsewidget/node_modules/react-spin/src/main.js Line 29: Unexpected token <
You may need an appropriate loader to handle this file type.
| render: function() {
| return (
| <span ref="container" />
| );
| }
@ ./js/widget.jsx 4:14-35
我猜該模塊中有jsx,但我不明白爲什麼它不能被構建?構建捆綁包時反應旋轉是否需要一些額外的配置?
這裏是我的全webpack.config.js:
module.exports = {
entry: "./js/widget.jsx",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.jsx$/,
loader: 'jsx-loader?insertPragma=React.DOM&harmony'
}
]
},
externals: {
//don't bundle the 'react' npm package with our bundle.js
//but get it from a global 'React' variable
'react': 'React'
},
resolve: {
extensions: ['','.js','.jsx']
}
};
謝謝,你提出了一個很好的觀點。我最終在自己的項目中包含了自己的反應。 – ApathyBear