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.

How to include a custom SCSS theme? (Add standalone stylesheet files to packages)

See original GitHub issue

Type of Issue

[ ] Bug Report
[x] Feature Request
[x] Documentation Request/Question

Description

I have an existing component library that includes a SCSS theme, similar to what Angular Material does. I’m currently using Gulp+Rollup to build that library, and I’ve basically copied what Angular Material does in order to get my theme to be bundled and distributed inside the package. I’m using the scss-bundle package to bundle/generate a single theming file, and copying the result to the dist folder.

Is there any way to accomplish that using ng-packagr? I first tried adding a secondary module, but since there is no JS/TS code involved in the theming, it’s not going to pick it up.

How To Reproduce

Expected Behaviour

Version Information

ng-packagr: v1.4.1
@angular: v4.4.6

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

30reactions
rpd10commented, Nov 16, 2017

I was able to get it working very simply using scss-bundle. Here’s what I did:

  1. yarn add -D scss-bundle
  2. Add a scss-bundle.config.json at the root, next to package.json
{
  "entry": "./src/lib/theming/_all-theme.scss",
  "dest": "dist/_theming.scss"
}
  1. Update package.json scripts to modify the build target and add a target for bundling:
...
"build": "ng-packagr -p ng-package.json && yarn bundle-styles",
"bundle-styles": "scss-bundle -c scss-bundle.config.json"
...

Voila, running yarn build will create the package and then spit out the bundled scss into the dist directory alongside the package.

27reactions
FirstVertexcommented, Nov 14, 2018

I dislike these solutions involving a post build step. None of this can be applied when using ng build --watch=true Developer workflow with HMR goodness is lost. We need a built-in way to copy scss to dist without the post build hack.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass · Bootstrap v5.1
In your custom.scss , you'll import Bootstrap's source Sass files. You have two options: include all of Bootstrap, or pick the parts you...
Read more >
The complete guide to customizing a Tailwind CSS theme
The complete tutorial on creating a custom Tailwind CSS theme, including installing Node.js and setting up the PostCSS build process.
Read more >
Customization - Material for MkDocs - GitHub Pages
The easiest way is by creating a new style sheet file in the docs directory: ... or add some custom logic to your...
Read more >
CSS Themes - JavaScript Scheduler - DayPilot Documentation
Include the theme CSS in the page (usually it will be a standalone CSS file). Set the theme to be used using the...
Read more >
How to add Tailwind CSS to HTML? - Themesberg
Learn how to quickly add Tailwind CSS to your HTML using CDN or learn the advanced method of using a package manager and...
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