I have a app that runs just fine with "ng serve". BUT if I try to retrieve another (static) html file that is in my src directory, I get a 304 and it just serves up the angular app again. The only way that I can see that static html file is to change the app->index value in the .angular-cli.json file. But then my angular 2 app does not run. Is "ng serve" only meant for SPA so that it CANNOT serve up separate static html files? I wanted to have some exterior (not logged in) pages with a very different look than my "app". Just trying to find the least painful way, if there is one.
Any extra files you want to include in the build/serve should be added to the assets
property in .angular-cli.json
.
Thank you! works great now!
"assets": [
"src/favicon.ico",
"src/search.html",
"src/assets"
],
browse localhost:4200/search.html
enjoy :)
... aaaaand restart "ng serve" so the change takes effect. :)
I have spent literally hours trying this, with long directory/file names, restarting constantly and still nothing appears for my http request either in the browser or by using HttpClient.
http://localhost:4203/badge1.html
Not sure what it could be. I am using the latest stuff:
Angular CLI: 7.0.7
Node: 8.11.4
OS: win32 x64
Angular: 7.0.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular-devkit/architect 0.10.7
@angular-devkit/build-angular 0.10.7
@angular-devkit/build-ng-packagr 0.10.7
@angular-devkit/build-optimizer 0.10.7
@angular-devkit/build-webpack 0.10.7
@angular-devkit/core 7.0.7
@angular-devkit/schematics 7.0.7
@angular/cdk 6.4.7
@angular/cli 7.0.7
@angular/material 6.4.7
@ngtools/json-schema 1.1.0
@ngtools/webpack 7.0.7
@schematics/angular 7.0.7
@schematics/update 0.10.7
ng-packagr 4.4.5
rxjs 6.3.3
typescript 3.1.6
webpack 4.19.1
did you put it in "assets" in the angular json?
I did, but actually it seems I inadvertently was not setting it up correctly. Even though my target asset is down the directory structure a bit, I was able to access it finally.
angualr.json:
"assets": [
"src/favicon.ico",
"src/assets",
"src"
],
Reference - finally got a '200' - yay!
http://localhost:4203/app/sample/examples/elements/badge-example/badge1.html
Thanks for making me re-look at it.
I did, but actually it seems I inadvertently was not setting it up correctly. Even though my target asset is down the directory structure a bit, I was able to access it finally.
angualr.json:
"assets": [ "src/favicon.ico", "src/assets", "src" ],
Reference - finally got a '200' - yay!
http://localhost:4203/app/sample/examples/elements/badge-example/badge1.html
Thanks for making me re-look at it.
well, now we all learned something new
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Any extra files you want to include in the build/serve should be added to the
assets
property in.angular-cli.json
.