好多同学都有这个问题,版本不对,问题也很多,希望老师能出个最新的教程供大家参考
{ "name": "05-01", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "babel-preset-es2015": "^6.22.0", "babel-preset-react": "^6.23.0", "babelify": "^7.3.0", "react": "^15.4.2", "react-dom": "^15.4.2", "webpack": "^2.2.1", "webpack-dev-server": "^2.4.1" } }
下面是配置文件
var webpack = require('webpack'); var path = require('path'); module.exports = { context:__dirname+'/src', entry:"./js/index.js", module:{ loaders:[{ test:/.js?$/, exclude:/(node_modules)/, loader:'babel-loader', query:{ presets:['react','es2015'] } }] }, output:{ path:__dirname+"/src/", filename:"bundle.js" } };
轻松入门 React 开发,React Router 4 与 Webpack 2 完美升级项目
了解课程