@@ -15,6 +15,7 @@ const WebpackDevServer = require('webpack-dev-server');
15
15
const Task = require ( '../ember-cli/lib/models/task' ) ;
16
16
const SilentError = require ( 'silent-error' ) ;
17
17
const opn = require ( 'opn' ) ;
18
+ const yellow = require ( 'chalk' ) . yellow ;
18
19
19
20
export default Task . extend ( {
20
21
run : function ( serveTaskOptions : ServeTaskOptions , rebuildDoneCb : any ) {
@@ -52,7 +53,7 @@ export default Task.extend({
52
53
53
54
if ( serveTaskOptions . disableHostCheck ) {
54
55
ui . writeLine ( oneLine `
55
- ${ chalk . yellow ( 'WARNING' ) } Running a server with --disable-host-check is a security risk.
56
+ ${ yellow ( 'WARNING' ) } Running a server with --disable-host-check is a security risk.
56
57
See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
57
58
for more information.
58
59
` ) ;
@@ -77,27 +78,35 @@ export default Task.extend({
77
78
] ;
78
79
if ( serveTaskOptions . hmr ) {
79
80
const webpackHmrLink = 'https://webpack.github.io/docs/hot-module-replacement.html' ;
81
+
80
82
ui . writeLine ( oneLine `
81
- ${ chalk . yellow ( 'NOTICE' ) } Hot Module Replacement (HMR) is enabled for the dev server.
83
+ ${ yellow ( 'NOTICE' ) } Hot Module Replacement (HMR) is enabled for the dev server.
82
84
` ) ;
83
- ui . writeLine ( ' The project will still live reload when HMR is enabled,' ) ;
84
- ui . writeLine ( ' but to take advantage of HMR additional application code is required' ) ;
85
- ui . writeLine ( ' (not included in an Angular CLI project by default).' ) ;
86
- ui . writeLine ( ` See ${ chalk . blue ( webpackHmrLink ) } ` ) ;
87
- ui . writeLine ( ' for information on working with HMR for Webpack.' ) ;
85
+
86
+ const showWarning = CliConfig . fromGlobal ( ) . get ( 'warnings.hmrWarning' ) ;
87
+ if ( showWarning ) {
88
+ ui . writeLine ( ' The project will still live reload when HMR is enabled,' ) ;
89
+ ui . writeLine ( ' but to take advantage of HMR additional application code is required' ) ;
90
+ ui . writeLine ( ' (not included in an Angular CLI project by default).' ) ;
91
+ ui . writeLine ( ` See ${ chalk . blue ( webpackHmrLink ) } ` ) ;
92
+ ui . writeLine ( ' for information on working with HMR for Webpack.' ) ;
93
+ ui . writeLine ( oneLine `
94
+ ${ yellow ( 'To disable this warning use "ng set --global warnings.hmrWarning=false"' ) }
95
+ ` ) ;
96
+ }
88
97
entryPoints . push ( 'webpack/hot/dev-server' ) ;
89
98
webpackConfig . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) ) ;
90
99
if ( serveTaskOptions . extractCss ) {
91
100
ui . writeLine ( oneLine `
92
- ${ chalk . yellow ( 'NOTICE' ) } (HMR) does not allow for CSS hot reload when used
101
+ ${ yellow ( 'NOTICE' ) } (HMR) does not allow for CSS hot reload when used
93
102
together with '--extract-css'.
94
103
` ) ;
95
104
}
96
105
}
97
106
if ( ! webpackConfig . entry . main ) { webpackConfig . entry . main = [ ] ; }
98
107
webpackConfig . entry . main . unshift ( ...entryPoints ) ;
99
108
} else if ( serveTaskOptions . hmr ) {
100
- ui . writeLine ( chalk . yellow ( 'Live reload is disabled. HMR option ignored.' ) ) ;
109
+ ui . writeLine ( yellow ( 'Live reload is disabled. HMR option ignored.' ) ) ;
101
110
}
102
111
103
112
if ( ! serveTaskOptions . watch ) {
0 commit comments