I am trying to set up a hot restart webpack using a hot reaction reactor. It basically works. I am using webpack in an existing rails application.
But this is not a hot reboot. It just starts a reboot every time it changes the reaction code. I get error messages:
[HMR] Cannot apply update. Need to do a full reload! - dev-server.js:18 [HMR] Error: Aborted because 0 is not accepted - dev-server.js:19 at hotApply (http://localhost:8080/assets/webpack/bundle.js?body=1:380:31) at hotUpdateDownloaded (http://localhost:8080/assets/webpack/bundle.js?body=1:293:13) at hotAddUpdateChunk (http://localhost:8080/assets/webpack/bundle.js?body=1:273:13) at webpackHotUpdateCallback (http://localhost:8080/assets/webpack/bundle.js?body=1:5:12) at http://localhost:8080/assets/webpack0.bd89931b2fa8e2901794.hot-update.js:1:1 Navigated to http://lvh.me:3000/react_page
Here are my webpack.hot.config.js settings:
var path = require('path'); var webpack = require('webpack'); var config = module.exports = { // Set 'context' for Rails Asset Pipeline context: __dirname, entry: { App: [ 'webpack-dev-server/client?http://localhost:8080/', // WebpackDevServer host and port 'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors './app/frontend/javascripts/app.js' // Your appสผs entry point ], vendor: ['jquery', 'react', 'react-dom', 'react-redux', 'redux','redux-thunk'] }, devtool: 'inline-source-map', // Require the webpack and react-hot-loader plugins plugins: [ //new webpack.HotModuleReplacementPlugin(), new webpack.optimize.CommonsChunkPlugin( { name: 'vendor', chunks: [''], filename: 'vendor.js', minChunks: Infinity }), new webpack.NoErrorsPlugin(), new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jquery': 'jquery' }) ], module: { loaders: [ { test: /\.jsx?$/, exclude: /node_modules/, loaders: [ 'react-hot', 'babel?presets[]=es2015&presets[]=react' ], cacheDirectory: true } ] }, output: { path: path.join(__dirname, 'app', 'assets', 'javascripts', 'webpack'), // Save to Rails Asset Pipeline filename: 'bundle.js', // Will output App_wp_bundle.js publicPath: 'http://localhost:8080/assets/webpack', //publicPath: 'http://localhost:8080/assets/webpack' // Required for webpack-dev-server }, resolve: { extensions: ['', '.js', '.jsx'], modulesDirectories: ['node_modules'], }, };
And I run the code with
webpack-dev-server -d --config webpack.hot.config.js --hot --inline
The rails development environment maintains webpack files outside the application resource pipeline through the webpack-dev server due to the following setting in my development.rb file.
config.action_controller.asset_host = Proc.new { |source| if source =~ /webpack\/bundle\.js$/i "http://localhost:8080" end }
I tried to get this work for hours. Any help would be greatly appreciated.
Thanks guys!