angular-cli: ng serve recompile time very slow
Using ‘ng serve’ the webpack compile and recompile on code changes takes sometimes more than a minute.
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.0 node: 7.6.0 os: darwin x64 @angular/common: 4.0.3 @angular/compiler: 4.0.3 @angular/core: 4.0.3 @angular/forms: 4.0.3 @angular/http: 4.0.3 @angular/platform-browser: 4.0.3 @angular/platform-browser-dynamic: 4.0.3 @angular/router: 4.0.3 @angular/cli: 1.0.0 @angular/compiler-cli: 4.0.3
Repro steps.
- ng serve
- make change to any file (json, ts, html)
- wait for browser to reload…
The log given by the failure.
$xxxx ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: 15921d5ca032c405df0a
Time: 43310ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 231 kB {5} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 389 kB {4} [initial] [rendered]
chunk {2} scripts.bundle.js, scripts.bundle.js.map (scripts) 515 kB {5} [initial] [rendered]
chunk {3} styles.bundle.js, styles.bundle.js.map (styles) 11.4 kB {5} [initial] [rendered]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.61 MB [initial] [rendered]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
webpack: Compiling…
Hash: 74ff0fd808586e648c85
Time: 52972ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 231 kB {5} [initial]
chunk {1} main.bundle.js, main.bundle.js.map (main) 389 kB {4} [initial] [rendered]
chunk {2} scripts.bundle.js, scripts.bundle.js.map (scripts) 515 kB {5} [initial]
chunk {3} styles.bundle.js, styles.bundle.js.map (styles) 11.4 kB {5} [initial]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.61 MB [initial]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
webpack: Compiled successfully.
Desired functionality.
Compile and reload in 3-5 seconds or so
Mention any other details that might be useful.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 21 (3 by maintainers)
I have this problem too without having any images or nothing, just modules and stuff. When changing a line of css sometimes it can take 30 sec to recompile. Really, really annoying. Something is clearly wrong somewhere, but I can’t pinpoint what could be causing it as I’m following the official styleguide and best practices in general when writing my modules/components etc.
@BambiB no offense, but no serious developer should be developing on a HDD nowadays
You can use this flag while compiling: ng serve --source-map=false
It take 10sec to compile now while previously it was taking 32sec. source-map is just used for debugging. So if not using debugger you can disable and compile.
Ok, I’ll look into that. I also saw that using
ng build --watch
might be an option.Thanks for your help, and all of your great work!
I was trying to figure out why my computer was slowing down and I realized ng was starting a new conhost.exe everytime it recompiled my site.
When one of you mentioned that it was because the asset files might be too big I realized that it was doing this whenever I made changes to my CSS file while running
ng serve
Kinda sucks that this happens because I’d like to use it like a live reload to see changes as I make them.
Just letting you guys know that’s a thing that happens.
Uff… yeah for that kind of asset size I think that’s better to copy them over in a script. The build pipeline watches over all the assets for changes, so it’s probably really stressing your system.
I don’t have any good way besides copying them over separately, I’m sorry 😕
I have this problem constantly. ng serve takes forever to start (sometimes >5 minutes). This isn’t with huge projects, or tiny memory constraints. In fact, just using ng new projectname and doing nothing else to the files, then trying to compile down/serve the files takes 45 seconds. This is on a MacBook Pro with 2.5GHz dual i5 processors and 16GB of ram.
I ran into this issue – Please make sure you don’t have anything in your
assets
folder that is excessively large. If you’renpm init
ting a separate project in a child directory, or something of this sort.