要崩溃了,刚开始学react配置这样的坏境各种出错,有没有最新的教程搭建环境呢?
webpackage.config.js这样的:
var webpack = require('webpack');
module.exports={
entry:'./js/index.js',
output:{
path:_dirname + '/js/',
filename:'bundle.js',
publicPath: '/js/'
},
module:{
loaders:[
{test:/\.js$/,loaders: ['babel-loader'],exclude: /node_modules/}
]
},
resolve:{
extensions:['','.js','.jsx']
}
};
server.js:
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config.js');
new WebpackDevServer(webpack(config),{
publicPath: config.output.publicPath,
hot:true,
historyApiFallback: true
}).listen(3333,'localhost',function(err,result){
if(err){
console.log(err);
}
console.log('Listen at localhost:3333');
});
index.js
var React = require('react');
var App = React.createClass({
render:function(){
return (
<h1>helloworld!!</h1>
);
}
});
ReactDOM.render(<App />,document.getElementById("app"));
错误信息:
出错是正常的,这你搭建的明显不支持ES6,话说你两个index.js里面的内容都不一样吧,好好配置babel吧,没配置成功。Babel