i have:
- angular2 application controlled by
angular-cli
ng serve
for dev purposes andng build
for production- some microservice which generates some images and copy them to static folder, in current situation - to
./src/assets
folder
problem:
files, that were added to this folder after ng serve
was executed are not visible by application throwing me next error:
Cannot match any routes. URL Segment: 'assets/test.png'
while other images that were present before ng serve
was executed are successfully fetching
steps to reproduce:
- init mock angular application with command
ng new my-app
- go to generated folder with command
cd my-app/
- create some test file in assets folder with command
echo "this file is visible because it was in folder before ng serve" >> src/assets/test.txt
- launch app with command
ng serve
- in another terminal window, check that recently created file is visible by url with command
curl localhost:4200/assets/test.txt
- verify that curl returned
this file is visible because it was in folder before ng serve
- add one more file without reloading
ng serve
with commandecho "don't matter because you'll get an error" >> src/assets/error.txt
- try to get that file with command
curl localhost:4200/assets/error.txt
- verify that you see error
Error
Cannot GET /assets/error.txt
- try to modify test.txt
echo "file modification is visible by live reload" >> src/assets/test.txt
- get updated file without reloading ng serve
curl localhost:4200/assets/test.txt
- verify that you see
this file is visible because it was in folder before ng serve file modification is visible by live reload
- create component with command
ng g component testcomponent
- modify app.component.html with command
echo "(open tag)app-testcomponent(close tag)(open tag)/app-testcomponent(close tag)" > src/app/app.component.html
(change open tag with < and close tag with >) - open localhost:4200 in browser and see
testcomponent works!
as you see from given steps - live reload do not track only new files in assets. newly added component is normally visible without restarting app
so, what i'm doing wrong? it's not very critical (i still can make production build and work with it) but makes some pain during app testing
is it bug or i can't find proper configuration to tell app to watch for incomers in assets also?
ng --version gives me next output
Angular CLI: 1.6.5
Node: 9.4.0
OS: darwin x64
Angular: 5.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.5
@angular-devkit/build-optimizer: 0.0.41
@angular-devkit/core: 0.0.28
@angular-devkit/schematics: 0.0.51
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.5
@schematics/angular: 0.1.16
typescript: 2.5.3
webpack: 3.10.0