Skip to content

Global SCSS Imports #832

Closed
Closed
@jkwill87

Description

@jkwill87

Is your feature request related to a problem? Please describe.

I have a scss file with variables I would like to use throughout my app without importing it in every <style> block.

Describe the solution you'd like

A configuration option in vite.config.js which directly or indirectly would allow users to prepend sass as is possible in vue.config.js using prependData or additionalData depending on your sass-loader version.

Describe alternatives you've considered

I noticed that vuejs/core#2126 was cited in reference to closing #520, a similar request, but I'm not sure how that's applicable to vite given that it doesn't use webpack and as far as I can tell doesn't use sass-loader.

Additional context

Another separate but related problem is that @import only seems to be working with relative paths; e.g. with the default project setup@import ./src/whatever.scss works fine but @import /src/whatever.scss does not. Supposing that is in fact the case and something like additionalData where possible to use in vite then relative paths would break for components in nested directories. Implementing #650 to resolve aliases in scss files might work though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions