Global style not loaded in Angular
See original GitHub issueDescribe the bug
I want to include a stylesheet file in my stories globally. However, the file is not loaded. My angular.json
looks like this (the last line contains the style inclusion):
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-project": {
"root": "..",
"sourceRoot": ".",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "./components/root/static/index.html",
"main": "./app.entry.ts",
"tsConfig": "./tsconfig.json",
"polyfills": "./app/app.dependencies.ts",
"assets": ["app/assets"],
"styles": ["app/assets/style/style.scss"],
System:
- OS: MacOS
- Browser: chrome
- Framework: angular 7.2
- Version: Storybook 4.1.4
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Angular 13. Global styles no longer work in SB 6.4 (CSS or ...
Styles in Angular project are now included into the SB build and it is working. Issues still to be resolved: External static styles,...
Read more >angular-cli how to add global styles? - Stack Overflow
Copy the global styles into src/styles.css · Use CSS imports to import external rules into styles.css · Add more global styles via the...
Read more >Angular Global CSS styles - TekTutorialsHub
There are several ways to add Global (Application wide styles) styles to the Angular application. The styles can be added inline, ...
Read more >Component styles - Angular
While Angular's default style encapsulation prevents component styles from affecting other components, global styles affect all components on the page. This ...
Read more >Avoid global styles in your Angular projects
Avoid global styles in your Angular projects · break encapsulation · poor readability · break information hiding · namespace pollution.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same problem with Storybook 4.1.6. Tried various solutions with
webpack.config.ts
but nothing worked. Component styles are loaded fine.Main problem: using global imports inside of a component e.g.
@import '~src/styles/variables
or@import 'variables'
will end up with storybook compilation error:ERROR in ./src/app/tab2/example/example.component.scss Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Either
File to import not found or unreadable: ~src/styles/variables.
orFile to import not found or unreadable: variables.
PS I have set preprocessor options like this:
Hey, any updates on this? We had to downgrade 2 angular devkit packages so storybook could read
angular.json
. But this isn’t really a viable solution.Storybook can read
angular.json
with the following packages