Skip to content

Add option to output styles inline #11395

Closed

Description

@filipbech

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Area

- [x] devkit
- [ ] schematics

Desired functionality

It would be cool if there was a build-option that would take the processed/minified css and put it inline in a <style>-element in index.html instead of as a seperate file.
Useful when it doesn't change so often, and the styles are limited.

Rob asked me to make a Feature-request... https://twitter.com/robwormald/status/1012084975766626304

Mention any other details that might be useful

Activity

  1. added
    featureLabel used to distinguish feature request from other issues
    on Jun 28, 2018
  2. christianliebel commented on Sep 21, 2018

    @christianliebel
    Contributor

    Useful for critical/“above-the-fold” CSS. Maybe it’s also possible to process the contents of a style tag in src/index.html?

  3. added this to the Backlog milestone on Jan 4, 2019
  4. slavoroi commented on Oct 28, 2019

    @slavoroi

    What is the status with this ticket?
    It will be amazing if we could have an option:

    "styles": [
          "src/styles.scss"
      ],
    "inline-styles": [
          "src/inline-styles.scss"
      ]
    

    Or

    "styles": [
          { "input": "src/inline-styles.scss", "inline": true }
      ]
    

    And it will add the styles in the index.html inline in the head with
    ng build ---prod.

  5. naveedahmed1 commented on May 29, 2020

    @naveedahmed1

    I would also suggest adding inline and preload options in styles in angular.json file

    "styles": [
          { "input": "src/critical-path-styles.scss", "inline": true },
          { "input": "src/lazy-styles.scss", "preload": true }
      ]
    

    With above settings, Angular CLI should inline the contents of critical-path-styles.scss in head tag, and it should generate <link href="/lazy-styles.96106fab.css" rel="preload" as="style" onload="this.rel='stylesheet'"> for lazy-styles.scss.

  6. added
    needs: investigationRequires some digging to determine if action is needed
    and removed
    needs: discussionOn the agenda for team meeting to determine next steps
    on Jun 5, 2020
  7. spock123 commented on Oct 25, 2020

    @spock123

    Hi, is there any hope of this ever becoming a feature?
    Running lighthouse tests just gives red lights all over because of this. It's a pretty common thing to inline resources and it would be a great cli feature.

    I would add that inlining the main bundle would also be a great feature.

    Thanks again

  8. alan-agius4 commented on Oct 25, 2020

    @alan-agius4
    Collaborator

    Hi,

    We did an RFC for this see: #18730.

    In the prerelease version of Angular CLI v11 inlining of fonts is already available, other parts of the RFC are scheduled to be available in 11.1.

  9. self-assigned this
    on Oct 25, 2020
  10. spock123 commented on Oct 25, 2020

    @spock123

    Hi,

    We did an RFC for this see: #18730.

    In the prerelease version of Angular CLI v11 inlining of fonts is already available, other parts of the RFC are scheduled to be available in 11.1.

    Yeah I actually heard @mgechev mention it on the latest Angular podcast - I'm so happy - this is YUUGE guys!
    Thank you so much

  11. added a commit that references this issue on Dec 4, 2020
    eb30a92
  12. naveedahmed1 commented on Dec 4, 2020

    @naveedahmed1

    Amazing work @alan-agius4 @clydin 👍

  13. spock123 commented on Dec 5, 2020

    @spock123

    I'm gonna pour myself a gin/tonic and celebrate this. Thank you @alan-agius4 !

  14. angular-automatic-lock-bot commented on Jan 5, 2021

    @angular-automatic-lock-bot

    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.

  15. locked and limited conversation to collaborators on Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions