diff --git a/package.json b/package.json index f131fbf6e2..f0d0e64c6d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,10 @@ "babel-core": "6.5.2", "babel-eslint": "5.0.0", "babel-loader": "6.2.3", + "babel-plugin-react-transform": "2.0.0", "babel-plugin-transform-class-properties": "6.5.2", + "babel-plugin-transform-decorators-legacy": "1.3.4", + "babel-plugin-transform-object-rest-spread": "6.5.0", "babel-preset-es2015": "6.5.0", "babel-preset-react": "6.5.0", "babel-preset-stage-2": "6.5.0", @@ -47,6 +50,7 @@ "history": "2.0.0", "react-dom": "0.14.7", "react-hot-loader": "1.3.0", + "react-transform-hmr": "1.0.2", "semver": "5.1.0", "shelljs": "0.6.0", "webpack": "1.12.14", diff --git a/src/core/server/base.js b/src/core/server/base.js index dc40424c55..db5bd3abb0 100644 --- a/src/core/server/base.js +++ b/src/core/server/base.js @@ -45,6 +45,7 @@ export default function(routes) { })); if (ENV === 'development') { + console.log('Adding Webpack Dev Server'); // eslint-disable-line no-console devServer(app); } diff --git a/src/core/server/dev.js b/src/core/server/dev.js index cc2de2e146..d93f33f70d 100644 --- a/src/core/server/dev.js +++ b/src/core/server/dev.js @@ -7,6 +7,22 @@ import config from 'config'; const APP_NAME = config.get('currentApp'); +const BABEL_QUERY = { + presets: ['react', 'es2015'], + plugins: [ + ['transform-object-rest-spread'], + ['transform-class-properties'], + ['transform-decorators-legacy'], + ['react-transform', { + transforms: [{ + transform: 'react-transform-hmr', + imports: ['react'], + locals: ['module'], + }], + }], + ], +}; + export default function(app) { const conf = Object.assign(webpackConfig, { devtool: 'inline-source-map', @@ -14,6 +30,14 @@ export default function(app) { 'webpack-hot-middleware/client', `./src/${APP_NAME}/client`, ], + module: { + loaders: [{ + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel', + query: BABEL_QUERY, + }], + }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(),