React es6 webpack 環境懶人包紀錄
請確認已安裝webpack
npm
npm install react react-dom babel-loader babel-preset-es2015 babel-preset-react --save-dev
webpack.config.js
var path = require('path'); var config = { entry: path.resolve(__dirname, 'resources/assets/js/xxx.js'), output: { path: path.resolve(__dirname, 'public/js'), filename: 'bundle.js' }, resolve: { extensions: ['', '.js', '.jsx'] }, module: { loaders: [ { test: /.jsx?$/, exclude: /node_modules/, loader: 'babel', query: { presets: ['es2015', 'react'] } } ] } }; module.exports = config;
<code class="EnlighterJSRAW" data-enlighter-language="null">webpack -w
即可