Workspace library scss import
- Langage dominant
- TypeScript
- Étoiles
- 27k
- Forks
- 11.8k
- Merge moyen
- 14 h 23 min
- PR mergées (30 j)
- 162
Description
# 🚀 Feature request
### Command (mark with an `x`)
- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
### Description
With a workspace architecture, the exported stylesheets cannot be imported using package name. Given a library (`lib`) and a project (`app`) in an angular workspace. The library properly copies an scss file to the `dist` folder (which is the default output folder) and adds it to the `exports` section of the `package.json`. However, the consuming app cannot `@import` or `@use` the exported scss file.
Given the following files:
- dist/my-company/my-lib/assets/_theme.scss
- projects/app/src/styles.scss
And the following export in the `package.json` of the library:
```
"exports": {
"./theme": {
"sass": "./assets/_theme.scss"
}
},
```
And the default settings that the Angular CLI generates (with `ng new library` and so on...),
### Describe the solution you'd like
With the settings mentioned above, importing an exported scss file should work out of the box (currently it does not compile with the error `SassError: Can't find stylesheet to import.`).
```
// styles.scss
@use "@my-company/my-lib/theme" as myTheme;
```
### Describe alternatives you've considered
1. Changing the default `dist` output of the library to the `node_modules` and the automatically removed `@` symbol is added to the path (in short `dist/my-company/my-lib` -> `node_modules/@my-company/my-lib`) resolves the scss import problem. The `tsconfig.json` must be adjusted as well. If this is the desired solution, then it should be the default generated with the CLI.
2. Create an NPM Link to the dist directory (which has its own pros and cons). If this is the desired solution, then the `tsconfig.json` does not need to define additional `paths` and this should be an operation that the generation (through the CLI) does automatically. Or at least extend [the documentation](https://angular.io/guide/creating-libraries#managing-assets-in-a-library).
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par les chemins de build et de generate d’une bibliothèque de workspace, en utilisant dist/my-company/my-lib/assets/_theme.scss, l’entrée exports de package.json et projects/app/src/styles.scss comme points de reproduction. Exécutez l’importation @use de l’application et examinez les paramètres du tsconfig.json généré ; le travail est terminé lorsque le SCSS exporté se résout sans contournement manuel de chemin ou de npm-link.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, scss, typescript
- Domaine
- build-system, cli, frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100