Hot Module Reloading using the Angular CLI Addon

Addins aren’t officially supported yet, but you can hack the source to plug in your custom addin.

First do the CLI linking and Project Scaffolding like so:

Next, Install the HMR stuff: npm i -D @angularclass/hmr @angularclass/hmr-loader
Create a shared/hmr.class.ts, copying this:
Have app.module.ts import and extend it:

Finally in the linked Angular CLI repo that you originally cloned from gitHub, change the following:


config.entry.main.unshift(`webpack-dev-server/client?http://${}:${commandOptions.port}/`, 'webpack/hot/dev-server');

const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = {
  contentBase: path.resolve(this.project.root, `./${CliConfig.fromProject().defaults.sourceDir}`),
  historyApiFallback: true,
  stats: webpackDevServerOutputOptions,
  inline: true,
  hot: true // add this

Lastly,Add this AT 1st POSITION to plugins inside node_modules/angular-cli/addon/ng2/models/webpack-build-common.ts: new webpack.HotModuleReplacementPlugin(),


2 thoughts on “Hot Module Reloading using the Angular CLI Addon”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s