Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Style bundle in not adding angular cli ssr #1439

Closed
chamikasandamal opened this issue Dec 13, 2017 · 4 comments
Closed

Style bundle in not adding angular cli ssr #1439

chamikasandamal opened this issue Dec 13, 2017 · 4 comments

Comments

@chamikasandamal
Copy link

I'm just using the template created on #1288. i was not able to include styles bundles for server side rendering. everything looks fine and styles.bundle.js is generated inside the dist-server but it is not adding to the source.
here is the new app created for ssr in cliconfig

{
  "name": "ssr",
  "root": "src",
  "outDir": "dist-server",
  "assets": [
    "assets"
  ],
  "main": "main.server.ts",
  "tsconfig": "tsconfig.server.json",
  "prefix": "app",
  "styles": [
    "./styles/styles.scss"
  ],
  "scripts": [],
  "environmentSource": "environments/environment.ts",
  "environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  },
  "platform": "server"
}
@SteveSandersonMS
Copy link
Member

Adding the styles to your styles array in .angular-cli.json isn't enough, because that only controls what gets built - it doesn't import it into the HTML. You need to load your styles into a specific Angular component using the styleUrls property.

@chamikasandamal
Copy link
Author

But it is enough for the browser bundle. Client side rendering working without any issue with same configuration.

@chamikasandamal
Copy link
Author

@SteveSandersonMS : As far as i know styleUrls is for component level styles and styles array is for global styles(like vendor styles). for the client bundle setting styles array will generate separate bundle and inject that to html by angular CLI. but for server bundle asp-prerendering will not do that. so i still feel this is a bug. please revisit

@SteveSandersonMS
Copy link
Member

@chamikasandamal Ah, OK, I see what you're trying to do. Also I see your point that it would make sense for platform:server rendering to include the styles specified in .angular-cli.json. However this is not something controlled by the template here - that behaviour comes from Angular CLI's platform:server feature. So if you'd like Angular server-side rendering to handle this differently, could you report this to the Angular CLI project?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants