7

I have created a style library in our Nx Workspace with the --publishable flag. This is because we will need to publish the styles as an npm package to use the styles in other products that aren't in our Nx Workspace.

I have done this previously using a webpack.config.js but am trying to do this via the Nx commands.

When I run the Nx:build command it doesn't include the scss files (as expected). To get round this, I tried:

Attempts to make it work

I added this to the angular.json file in project/{{lib-project}}/architect/build/options

"stylePreprocessorOptions": {
  "includePaths": [
    "src/style-paths"
  ]
}

This fails with the message:

———————————————————————————————————————————————

> nx run shared-ui:build:development --watch 
'stylePreprocessorOptions' is not found in schema

———————————————————————————————————————————————

Trying this with the styles or assets tags give me the same warnings.

It appears these work when the projectType is application but fails when it is library.

Why are these errors happening when according to the docs there is no mention of these being projectType specific.

Any help with how are you meant to compile the SCSS files without these commands in Nx?

TL;DR

I want to create a publishable styles lib to push to npm but it's unclear how to compile and move the SCSS, without using webpack, to the generated dist folder.

Bren Gunning
  • 153
  • 2
  • 9
  • whats part is not working for you ? can you explain in simple short way ? – Developer Nov 11 '21 at 17:08
  • 1
    I can’t get my SCSS files (or compiled CSS files) to appear in the generated dist folder. Any way I add them to the angular.json file causes errors at build time. – Bren Gunning Nov 11 '21 at 18:40
  • https://stackoverflow.com/questions/57164159/stylepreprocessoroptions-angular-8 may be this link helpful to you – Developer Nov 11 '21 at 18:47
  • 2
    That references a projectType of application again though, which works already. It's when the projectType is library that it doesn't work. – Bren Gunning Nov 12 '21 at 10:10
  • @BrenGunning did you find solution for your problem ? – ATHER Nov 11 '22 at 01:51

0 Answers0