vscode-scss icon indicating copy to clipboard operation
vscode-scss copied to clipboard

Feature request: define include paths

Open mafredri opened this issue 8 years ago • 20 comments
trafficstars

I would like to be able to configure include paths so that @import statements can reference the correct file.

Consider the following configuration:

"scss.includePaths": ["src", "global/lib"]

And a .scss-file:

@import 'variables';

The following paths (relative to project root) would be considered as valid imports (and the intellisense would also recognize the first match as the actual import):

src/variables.scss
src/_variables.scss
global/lib/variables.scss
global/lib/_variables.scss

Does this seem reasonable?

PS. Discovered this extension today, loving it so far. Keep up the good work!

mafredri avatar May 08 '17 14:05 mafredri

Would be really useful when developing with libraries like bootstrap where the pulled SCSS files are in node_modules folder. With includeFiles I could tell vscode-scss to take variables from bootstrap as well.

muuvmuuv avatar Apr 05 '19 18:04 muuvmuuv

Can you clarify why this is needed? And how are you compilation this without sass errors?

When you import variables, it should only resolve to either variables.scss or _variables.scss.

octref avatar Nov 15 '19 16:11 octref

We need this for projects made with Angular. We define in the configuration file the folder where SASS has to resolve all the imports. Example (angular.json):

"stylePreprocessorOptions": {
  "includePaths": [
    "src/styles"
  ]
 }

On a component style:

@import 'utils/variables';

savilaf avatar Dec 23 '19 12:12 savilaf

+1 for this feature. I'm unable to get autocomplete from functions imported from node_modules folder via @import ~module/sassfile

ghaschel avatar Feb 27 '20 16:02 ghaschel

+1 For my webpack project I have set webpack and sass-loader include path as so:

// ...
options: {
  includePaths: [path.resolve(__dirname, './src')],
  // ...
}
// ...

So that instead of @use '../../../../styles/variables/colors'; I can write @use 'styles/variables/colors'; That compiles just fine, so I would like some intellisense for that.

jabuj avatar Mar 18 '20 11:03 jabuj

I too would like to see better support for angular projects. In an angular project, you can define includePaths in angular.json. This tells the angular setup (webpack under the hood if I am not mistaken) where to look for scss files. This works fine when you compile the code - but VS Code is not able to show intellisense for imports.

SuneRadich avatar Apr 28 '20 07:04 SuneRadich

Webstorm handles this in a really simple, effective way - you right-click (a fabulous invention - hint) and there is an option to include the folder as "assets". From then on sccs @imports consider these paths and viola you can navigate to the files

alastair-todd avatar May 28 '20 11:05 alastair-todd

Plus one from me too for this feature.

ekr3peeK avatar Jul 02 '20 23:07 ekr3peeK

I hope that vs code support this feature.

dbwodlf3 avatar Aug 10 '20 10:08 dbwodlf3

I also need this feature for the Nrwl Nx workspace to share styles between libs

kazamov avatar Oct 19 '20 12:10 kazamov

4 years and this is still a feature request?

This is so important for scss development!

mathiasrw avatar Jan 18 '21 13:01 mathiasrw

@mathiasrw, feel free to add this feature if you think it is so important for scss development

JakeChampion avatar Jan 18 '21 14:01 JakeChampion

Any update on this? I also would like to have this feature.

stasberkov avatar Feb 16 '22 14:02 stasberkov

This one would be great for angular projects, without it you always have to use relative paths which is really annoying in big angular applications.

JonasLuechau avatar Mar 21 '23 11:03 JonasLuechau

Is this still the case? VS Code has native SCSS support now, and you only need this extension for SASS, as I am aware.

muuvmuuv avatar Mar 21 '23 11:03 muuvmuuv

This still doesn't work sadly. "@use 'colors';" doesn't work, "@use '../../colors';" does (assuming it would be a correct path). Both builds fine, but no autocomplete or being able to find the file is hard to work with.

Is this not in the scope of the extension?

JonasLuechau avatar Mar 24 '23 09:03 JonasLuechau

please add support for this, this is a big pain point in my process !

LeonFedotov avatar Aug 31 '23 08:08 LeonFedotov

up

sutkovoy avatar Sep 15 '23 11:09 sutkovoy

Why issue has label "Need More details"? What else details are needed?

stasberkov avatar Sep 15 '23 13:09 stasberkov

There's are no more details needed. A contributor is rather needed, as this project seems to be dead.

Nagell avatar Sep 27 '23 10:09 Nagell