Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import some scss files into library component scss throw errors #1631

Open
robertIsaac opened this issue May 7, 2020 · 6 comments
Open

import some scss files into library component scss throw errors #1631

robertIsaac opened this issue May 7, 2020 · 6 comments

Comments

@robertIsaac
Copy link

robertIsaac commented May 7, 2020

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

when trying to import bootstrap mixins @import "~bootstrap/scss/mixins"; it throw the following error ERROR: Can't find stylesheet to import.

How To Reproduce

clone
https://github.com/robertIsaac/scss-reproduce
run ng build

Expected Behaviour

to build successfully

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            9.1.3
@angular/compiler:     9.1.4
rollup:                2.7.5
tsickle:
typescript:            3.8.3

Please include all version numbers that might be relevant, e.g. third-party libraries

bootstrap: 4.4.1

notes

this is created by suggestion of angular/angular-cli#17660 (comment)

i do another two imports and they are working fine

@import "~boosted/scss/functions";
@import "~boosted/scss/variables";
@import "~boosted/scss/mixins";

and changing the import to
@import "~boosted/scss/_mixins"; will make the build run successfully

it can be related to that there is a directory named mixins inside the bootstrap/scss directory, it's just a a guess

@Sapendo
Copy link

Sapendo commented Nov 28, 2020

Any updates?

@lars-berger
Copy link

The issue is that ng-packagr doesn't respect the sass property in Bootstrap's package.json.

Take for example an NPM package that has a package.json which looks like this:

{
  "name": "@my-app/styles",
  "version": "1.0.0",
  "sass": "src/main.scss"
}

If you attempt to consume that library within an ng-packagr library, it won't work.

// app.component.scss

@import '~@my-app/styles'; // <-- Will throw 'ERROR: Can't find stylesheet to import.'
@import '~@my-app/styles/src'; // However, this will work.

This gets even more hacky if you want to use the modern @use syntax, since the namespace changes (eg. @use '~@my-app/styles/src' as styles;).

Angular does in fact respect the sass property, which creates inconsistencies between how stylesheets are imported in libraries vs. apps.

@lars-berger
Copy link

@flash-me It's an issue because it's a convention that Angular follows, but ngpackagr does not. Respecting the "sass" property is expected behavior, which is why this bug report was created in the first place

@lars-berger
Copy link

@flash-me Tailwind uses the "styles" property, which is just an alias for "sass" (more common among CSS libraries, since it doesn't even use SASS). You'll find that pretty much every CSS/SCSS library has a "sass" or "styles" in their package.json. Not to mention there's also people who use monorepos and run into into this issue when separating their stylesheets into a library (my personal use case).

@nhhockeyplayer
Copy link

why cant this be fixed?
who is holding down this repo?
this should have been part of the functionality prior to this even being public
is the code that brittle?

@Wlada
Copy link

Wlada commented Feb 1, 2023

Any workaround for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants