Skip to content
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

Vite build not working if SCSS global variable is configured #45

Open
hihabib opened this issue Apr 10, 2024 · 0 comments
Open

Vite build not working if SCSS global variable is configured #45

hihabib opened this issue Apr 10, 2024 · 0 comments

Comments

@hihabib
Copy link

hihabib commented Apr 10, 2024

Below is my vite.config.js file

import {defineConfig} from "vite";
import vituum from "vituum";

export default defineConfig({
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `@use "src/styles/_variable.scss" as *;`
            }
        },
    },
    plugins: [
        vituum({
            imports: {
                filenamePattern: {
                    '+.css': [],
                    '+.scss': 'src/styles'
                },
                
            }
        })
    ]
})

if I remove vituum plugin and restructure my project files like vite default project structure, it works file. Scss works in dev mode and it builds well. But the problem arise when I use vituum plugin in my vite project. After configuring vituum in my project, to use global variable in SCSS when I set the below code in my vite config

css: {
       preprocessorOptions: {
           scss: {
               additionalData: `@use "src/styles/_variable.scss" as *;`
           }
       },
   },

the project run well in development mode, mean with npx vite. But it doesn't work when wanna build my project.

When I use npm run build ( I use pnpm) the error happens.

PS D:\Personal\test> pnpm build
> [email protected] build D:\Personal\test
> vite build                       

vite v5.2.8 building for production...
✓ 3 modules transformed.
x Build failed in 338ms
error during build:
Error: Module loop: this module is already being loaded.
9:15)
    at _wrapJsFunctionForAsync_closure.call$2 (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:35977:1
2)
    at _awaitOnObject_closure.call$1 (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:35965:32)       
    at Object._rootRunUnary (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:5332:18)
    at StaticClosure.<anonymous> (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:115670:16)
    at _CustomZone.runUnary$2$2 (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:37410:39)
    at _Future__propagateToListeners_handleValueCallback.call$0 (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sa
ss.dart.js:36473:51)
    at Object._Future__propagateToListeners (D:\Personal\test\node_modules\.pnpm\[email protected]\node_modules\sass\sass.dart.js:5125:93) 
 ELIFECYCLE  Command failed with exit code 1.

when I try to remove vituum. it runs well and builds well. But when I configure vituum, it runs well but doesn't build well. I have tried a lot to use global variable in scss in vite with vituum. But vituum generating error. By the way, I have tried without and with multiple template engine when I use vituum. But it doesn't work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant