question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

angular-cli ignores scss files compilation which are not imported into styles.scss

See original GitHub issue

OS?

All

Versions.

All

Repro steps.

Let say I want to have theme scss files for my application which I wan’t to load at run time based on the theme chosen by the user.

I don’t want to import the theme files such as “theme-light.scss”, “theme-dark.scss” and so on… all the files into “styles.scss” since that way I end up loading all the theme css files loading upfront as part of the initial payload which I want to avoid.

So ng serve it doesn’t compile theme scss files to css files repectively for each theme. Is there a way we can target external sccs files compilation which are actually not part of styles.scss file ?

Once I am able to compile the theme scss files i want to dynamically load theme via javascript code and injected into my index.html as shown below

// when theme “light” is selected <-- index.html -->

<link href="styles.bundle.css" rel="stylesheet">
// css loaded via javascript and inject into html
<link href="assets/scss/theme-light.css" rel="stylesheet" type="text/css" title="dark">

// when theme “dark” is selected <-- index.html -->

<link href="styles.bundle.css" rel="stylesheet">
<link href="assets/scss/theme-light.css" rel="stylesheet" type="text/css" title="light" disabled>
<link href="assets/scss/theme-dark.css" rel="stylesheet" type="text/css" title="dark">

Hope you guys get the idea about the problem and what I am trying to achieve.

Thanks, Bhasker

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
beemancommented, Jan 25, 2017

@bhaskerchari here is an example of an app that does theming, built on angular-cli: https://github.com/housseindjirdeh/angular2-hn

It’s more a matter of how you structure your app/themes using scss, not so much an angular-cli thing.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Exclude sass files from ng-build? - Stack Overflow
There should not be SCSS files, unless you define them in assets ( instead of styles ) in .angular-cli.json . Try a simple...
Read more >
Component styles - Angular
One way to do this is to set the styles property in the component metadata. The styles property takes an array of strings...
Read more >
sass-loader - webpack - JS.ORG
Chain the sass-loader with the css-loader and the style-loader to immediately ... CSS and Sass files have no special syntax for importing relative...
Read more >
Sass: @import
Sass extends CSS's @import rule with the ability to import Sass and CSS stylesheets, providing access to mixins, functions, and variables and combining ......
Read more >
This is how angular-cli/webpack delivers your CSS styles to ...
Have you ever wondered how is it possible to import CSS into JavaScript files? In this article I'll show you how Webpack does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found