-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Sass Deprecation Warning when building Vue project with Vite #18164
Comments
Start a new pull request in StackBlitz Codeflow. |
Try replacing |
A bit different error text showing in Deprecation [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
More info: https://sass-lang.com/d/legacy-js-api |
Also changed |
Add import { defineConfig } from 'vite';
export default defineConfig({
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
}); |
Thank you for the suggested solution. I've tested it and would like to share my findings:
To avoid this error, I had to remove the While the proposed solution does address the initial deprecation warning, I believe this issue should not be considered closed for the following reasons:
Regarding the Possible solutions to explore:
I would appreciate if the Vite team could look into these issues further:
This would ensure that users can benefit from both the latest Sass features and Vite's excellent developer experience, including accurate sourcemaps. |
iirc there is 1 issue about sources, iirc Hiroshi fixed it, maybe not yet released. EDIT: PR still open #18113 |
Thank you for the information. I appreciate the update on the status of these issues. I'll keep an eye on #18113 for further developments. Is there anything else I should be aware of or any temporary workarounds you'd recommend in the meantime? |
Also I have an additional question regarding the Sass API in Vite: Is there already a PR in progress to update Vite to use the modern Sass API by default? Or will we need to continue using the following configuration for the foreseeable future: preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
}, I'm currently working on a project that will soon go into production, and I want to ensure everything is set up correctly to avoid future issues. What would you recommend as the best approach for a production-ready setup regarding Sass compilation in Vite? Also, are there any known issues or limitations with using the 'modern-compiler' API that I should be aware of for a production environment? Your insights would be greatly appreciated as I want to make informed decisions for the long-term stability of the project. |
use preprocessorOptions: {
sass: {
api: 'modern-compiler',
},
}, |
I cannot help/suggest you about scss/sass, I'm not an expert sorry, I'm helping Hiroshi with some tests and Nuxt 3 integration in Vuetify Nuxt module. |
No, using Deprecation [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
More info: https://sass-lang.com/d/legacy-js-api |
How about adding both? |
With both, behaviour is same as without |
@matvejs16 Both are in plan. First one is a breaking change for Vite users relying on custom options https://vitejs.dev/config/shared-options.html#css-preprocessoroptions so #17937 will be included in Vite 6 release. Until then, it needs to be opt-in. Second one is a bug and as userquin said, it will be fixed by #18113. |
I just noticed that sass's deprecation warning link includes a nice guide for Vite https://sass-lang.com/documentation/breaking-changes/legacy-js-api/#bundlers, so I think it should be easy for users to discover what to do. I'll close this issue as we already have an issue for sourcemap. |
Describe the bug
When using Vite with SCSS, a deprecation warning is displayed regarding the legacy JS API for Dart Sass. This warning appears despite Vite's built-in support for CSS pre-processors, including Sass. The warning message is as follows:
This issue is related to Vite's handling of Sass compilation, as Vite documentation states that it provides built-in support for
.scss
and.sass
files without the need for additional plugins:The problem occurs in a clean Vite project with SCSS installed, indicating that it's not specific to any particular framework like Vue.
Reproduction
https://stackblitz.com/edit/vitejs-vite-icvcyy?file=index.html
Steps to reproduce
npm create vite@latest
)npm add -D sass
).scss
file (e.g.,src/style.scss
) and import it in your main JavaScript file$font-stack: Helvetica, sans-serif; body { font: 100% $font-stack; }
)npm run dev
) or build the project (npm run build
)These steps can be seen in action in the provided StackBlitz reproduction.
Note: The warning appears during both development and build processes of a Vite project that uses Sass/SCSS.
System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: