You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came about this as a part of considering how to build a component library for an angular project. It struck me like a thunderbolt after reading @clydin 's commenting saying that the ideas put out by @angular/material2 with imports via ~are unsupported
I've also spent a fair bit of time reviewing how webpack's sass-loader works compared to how the AngularCompiler plugin handles loading paths via tsconfig.json. Hats off to @clydin for the new reliance on webpack.resolve for handling tsconfig.json compilerOptions.paths implementation in v7.0.0. Reviewing all of the PRs and issues on styles up to this point has led me to the following:
I think the current includePaths functionality is severely limiting and can lead to significant confusion. It's really nice to KNOW where your styles are coming from rather than guessing which path it happens to come from. To this idea, I'd really like to point out the developer experience from component library perspective (think @angular/material2). Specifically, I'd like to clarify via a simple example of how it feels to develop components that use dependent styles (variables, mixins, functions, etc).
Comparative Example
Let's imagine we treated typescript classes & files (critical application code) like how includePaths forces us to treat .scss/.css/.less files (I'd also argue these are critical application code).
import { Input };
//as opposed to:
//import { Input } from '@angular/core';
As an application maintainer, I'd feel terrified of having any clue as to what was going on with that reference. Who knows where Input is coming from, which dependency you're referring to and as such, what the class even does. I can't even imagine maintaining that for a week let alone long term.
Currently, this is the experience of an Angular dev working with any kind of styles.
Looking at this, I have no idea where util comes from, no appreciation for whether or not it's imported from my project or a dependency and no way of knowing how to find the file. If I go check includePaths I'm then stuck sifting through how ever many paths are listed there. I feel that it is less than stellar and thus needs to be re-considered.
I could be very wrong here as this is a naive solution, but after reviewing how webpack's resolve.alias works, taking advantage of it seems like a decent approach. At build time, we could copy the elements from projects.PROJECTNAME.architect.build.stylePreprocessorOptions.includePaths that have prefixes into resolve.alias and be good to go. You'd have to reference your style file in your component's stylesheet via an import '@namespace/util.scss' but having to include the filetype doesn't seem to be the end of the world. If it won't break anything, we could even include .scss,.css,.less in the resolve.extensions.
The text was updated successfully, but these errors were encountered:
damienwebdev
changed the title
Prefixable scss imports similar to tsconfig.json compilerOptions.paths
Prefixable scss imports similar to tsconfig.json's compilerOptions.paths
Oct 12, 2018
damienwebdev
changed the title
Prefixable scss imports similar to tsconfig.json's compilerOptions.paths
Prefixable style imports similar to tsconfig.json's compilerOptions.paths
Oct 14, 2018
CLI is the wrong layer to fix this. We want to call out to the existing toolchain using their supported semantics, not layer additional semantics into CLI.
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
Repro steps
sample.scss
projects.project.architect.build.stylePreprocessorOptions.includePaths
src/styles.scss
reference thesample.scss
file.sass-loader
Desired functionality
sample.scss
projects.project.architect.build.stylePreprocessorOptions.includePaths
but INCLUDE a prefix if desired.src/styles.scss
reference thesample.scss
file.Mention any other details that might be useful
Issues & PRs
Revisits #1791
Revisits #4003
Revisits #5287
Potential Solution for #9018
Discussion
I came about this as a part of considering how to build a component library for an angular project. It struck me like a thunderbolt after reading @clydin 's commenting saying that the ideas put out by @angular/material2 with imports via
~
are unsupportedI've also spent a fair bit of time reviewing how webpack's sass-loader works compared to how the AngularCompiler plugin handles loading paths via tsconfig.json. Hats off to @clydin for the new reliance on webpack.resolve for handling tsconfig.json
compilerOptions.paths
implementation in v7.0.0. Reviewing all of the PRs and issues on styles up to this point has led me to the following:I think the current includePaths functionality is severely limiting and can lead to significant confusion. It's really nice to KNOW where your styles are coming from rather than guessing which path it happens to come from. To this idea, I'd really like to point out the developer experience from component library perspective (think @angular/material2). Specifically, I'd like to clarify via a simple example of how it feels to develop components that use dependent styles (variables, mixins, functions, etc).
Comparative Example
Let's imagine we treated typescript classes & files (critical application code) like how
includePaths
forces us to treat.scss/.css/.less
files (I'd also argue these are critical application code).As an application maintainer, I'd feel terrified of having any clue as to what was going on with that reference. Who knows where
Input
is coming from, which dependency you're referring to and as such, what the class even does. I can't even imagine maintaining that for a week let alone long term.Currently, this is the experience of an Angular dev working with any kind of styles.
Looking at this, I have no idea where
util
comes from, no appreciation for whether or not it's imported from my project or a dependency and no way of knowing how to find the file. If I go checkincludePaths
I'm then stuck sifting through how ever many paths are listed there. I feel that it is less than stellar and thus needs to be re-considered.It would be much more sane to do something like:
Potential Solution
I could be very wrong here as this is a naive solution, but after reviewing how webpack's
resolve.alias
works, taking advantage of it seems like a decent approach. At build time, we could copy the elements fromprojects.PROJECTNAME.architect.build.stylePreprocessorOptions.includePaths
that have prefixes intoresolve.alias
and be good to go. You'd have to reference your style file in your component's stylesheet via animport '@namespace/util.scss'
but having to include the filetype doesn't seem to be the end of the world. If it won't break anything, we could even include.scss,.css,.less
in theresolve.extensions
.The text was updated successfully, but these errors were encountered: