How do you include scss …

1 minute read

How do you include scss files with publish assets?

Responses:

Probably just use a copy command after the build command. Or have the scss files inside the assets folder itself as assets will get moved into the build dist folder.

Thats what i thought :confused: I know packagr has support for this, i was suprised NX not copied it

Struggling with it too. I have a libs/shared/ui-styles library with some SCSS mixins. Adding this to the buildproperty in the angular.json of an app works:

"stylePreprocessorOptions": { "includePaths": [ "libs/shared" ] } I can do @import 'ui-styles/colors'; in a scss stylesheet in apps.

What I struggled with this afternoon, was having a feature-lib with components and scss, Webstorm was unaware of the additional includePaths and it showed as an error, but when building an app that included that feature-library, it works just fine

And on the other hand, if you would like to include for instance shared font-files, this can also be done in the angular.json file:

"assets": [ "apps/web-app/src/favicon.ico", "apps/web-app/src/assets", { "input": "libs/shared/ui-styles/fonts/", "glob": "*.*", "output": "/assets/fonts/" } ] In the build config of your app

Is that helpful, ?

Does this work when you publish to npm?

Ah, not sure, we don’t publish the libraries. They are only consumed by the apps in the same project.

What makes a angular/nx lib publishable? Does it then also have a build config in the architect definition in angular.json?

yes and in workspace.json.

tried this last snippet for my shared fonts, thanks!

It doesn’t work for me in prod, tho. Any hints?

Updated: