-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
[FEAT] Allow to define includePaths
in styleOptions for Angular compiler plugin
#139
Comments
Thanks @miluoshi. We don't use the sass plugin included with https://twitter.com/brandontroberts/status/1581824172547665920 You can fix it in your Vite config "Fixed the imports by adding includePaths with a relative path to the root of the workspace in the Vite config." css: {
preprocessorOptions: {
scss: {
includePaths: ['node_modules', `../../assets/scss`]
}
}
}, |
Hi @brandonroberts, thanks for your reply! I don't see very deep into the Vite + Angular build system so take my findings with a grain of salt. TL;DR: With the new proposed After debugging the build pipeline I have found that without the proposed new option our app won't build. I get errors like this:
The option is needed to compile a scss file with custom path alias in // vite.config.ts
import angular from '@analogjs/vite-plugin-angular';
import { workspaceRoot } from '@nrwl/devkit';
const commonStylesLocation = path.resolve(workspaceRoot, 'libs/ui/src/lib');
export default defineConfig(({ mode }) => ({
resolve: {
alias: {
'ui-common-styles': `${commonStylesLocation}/ui-common-styles`,
},
plugins: [
angular({
includePaths: [commonStylesLocation],
workspaceRoot,
inlineStylesExtension: 'scss',
}),
],
}); // libs/ui/src/lib/ui-common-styles/variables/colors.scss
@import 'ui-common-styles/variables/colors'; Maybe it's obvious, but I found it interesting during my debugging session that there are 2 pipelines that process the same sass files in our app. At first the stylesheets are processed by |
Here's the call sequence for processing scss by
By following this sequence I can see that passing Call sequence for Vite CSS transformer
|
I see. The esbuild compiler plugin is also processing SCSS, along with Vite. The fix seems reasonable to me. I've moved the plugin inside the |
Which scope/s are relevant/related to the feature request?
vite-plugin-angular
Information
Problem:
I want to be able to define custom path aliases for import paths in my scss stylesheets and I am not able to.
Angular+Webpack alternative:
@nrwl/angular:webpack-browser executor and Angular CLI allows me to define
stylePreprocessorOptions.includePaths
to define custom paths (except node_modules) to search for scss modules at.Solution:
createCompilerPlugin
function accepts 2nd parameterstyleOptions
, that can containincludePaths
property. That option is consumed by sass plugin.My proposed solution has two parts:
resolve.alias
from user Vite config here:analog/packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts
Line 85 in cee43a9
includePaths
that would push new paths to theincludePaths
option mentioned abovePlease let me know if you are ok with this solution 🙏
Describe any alternatives/workarounds you're currently using
No alternative exists except of patching the package
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: