我今天開始使用webpack
,我在運行時遇到了一些問題。Webpack模塊解析失敗。加載器反應和babel
基本上我需要一個應用程序使用react & es6
。婁你可以看到錯誤:
webpack.config.js
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './app/app.js',
output: {
path: 'dist',
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
stage: 0
},
include: __dirname + '/app'
},
]
},
plugins: [new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
hash: true,
filename: 'index.html',
inject: 'body'
})]
};
到目前爲止,我曾嘗試是安裝es2015
並配置爲
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
}
但我仍然收到相同的錯誤。
任何想法如何解決它?
依賴
"dependencies": {
"react": "^0.14.0",
"react-dom": "^0.14.2",
"react-redux": "^4.0.0",
"webpack-dev-server": "^1.12.1"
},
"devDependencies": {
"babel-loader": "^5.3.2",
"history": "^1.13.0",
"html-webpack-plugin": "^1.6.2",
"webpack": "^1.12.2"
}
你使用的是什麼版本的babel? –
@DominicTobias我已經更新了添加我在'package.json'中的依賴關係的問題。 – gon250
查看通過它[** _ Link _ **](http://stackoverflow.com/questions/33779162/how-to-get-get- reactjs到整合與 - 的WebPack/33779337#33779337)。在這種情況下,你需要像es6這樣的babel-presets,並且還有babel-core npm模塊 –