@@ -34,9 +34,23 @@ export default Task.extend({
34
34
35
35
// This allows for live reload of page when changes are made to repo.
36
36
// https://webpack.github.io/docs/webpack-dev-server.html#inline-mode
37
- config . entry . main . unshift (
37
+ let entryPoints = [
38
38
`webpack-dev-server/client?http://${ serveTaskOptions . host } :${ serveTaskOptions . port } /`
39
- ) ;
39
+ ] ;
40
+ if ( serveTaskOptions . hmr ) {
41
+ const webpackHmrLink = 'https://webpack.github.io/docs/hot-module-replacement.html' ;
42
+ ui . writeLine ( oneLine `
43
+ ${ chalk . yellow ( 'NOTICE' ) } Hot Module Replacement (HMR) is enabled for the dev server.
44
+ ` ) ;
45
+ ui . writeLine ( ' The project will still live reload when HMR is enabled,' ) ;
46
+ ui . writeLine ( ' but to take advantage of HMR additional application code is required' ) ;
47
+ ui . writeLine ( ' (not included in an angular-cli project by default).' ) ;
48
+ ui . writeLine ( ` See ${ chalk . blue ( webpackHmrLink ) } ` ) ;
49
+ ui . writeLine ( ' for information on working with HMR for Webpack.' ) ;
50
+ entryPoints . push ( 'webpack/hot/dev-server' ) ;
51
+ config . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) ) ;
52
+ }
53
+ config . entry . main . unshift ( ...entryPoints ) ;
40
54
webpackCompiler = webpack ( config ) ;
41
55
42
56
const statsConfig = getWebpackStatsConfig ( serveTaskOptions . verbose ) ;
@@ -90,6 +104,8 @@ export default Task.extend({
90
104
webpackDevServerConfiguration . cert = sslCert ;
91
105
}
92
106
107
+ webpackDevServerConfiguration . hot = serveTaskOptions . hmr ;
108
+
93
109
ui . writeLine ( chalk . green ( oneLine `
94
110
**
95
111
NG Live Development Server is running on
0 commit comments