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

Undefined variable error when using sass @use (@import nd forward) #18682

Open
7 tasks done
Milan-960 opened this issue Nov 15, 2024 · 0 comments
Open
7 tasks done

Undefined variable error when using sass @use (@import nd forward) #18682

Milan-960 opened this issue Nov 15, 2024 · 0 comments

Comments

@Milan-960
Copy link

Milan-960 commented Nov 15, 2024

Describe the bug

I am trying to import my _variables.scss file in to my App.scss and it does not work and shows me an error

src/styles/App.scss 18:26  root stylesheet
18:38:35 [vite] Internal server error: [sass] Undefined variable.
   ╷
18 │   box-shadow: 0 6px 12px $box-shadow-light;
   │                          ^^^^^^^^^^^^^^^^^
   ╵
  src/styles/App.scss 18:26  root stylesheet
  Plugin: vite:css

I also tried this as well

@forward "./variables";

and it is not working at some points :( please help what else shall I do!

This is my vite.config.js


import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";

export default defineConfig({
  plugins: [react()],
  server: {
    port: 3000,
    host: true,
    strictPort: true,
  },
  build: {
    sourcemap: true,
    outDir: "dist",
    emptyOutDir: true,
    rollupOptions: {
      output: {
        manualChunks: {
          leaflet: ["leaflet", "leaflet-control-geocoder"],
          chartjs: ["chart.js", "react-chartjs-2"],
          react: ["react", "react-dom"],
        },
      },
    },
    chunkSizeWarningLimit: 600, // Adjust the limit if necessary
  },
  css: {
    preprocessorOptions: {
      scss: {
        // Use the new API for scss preprocessing in Vite
        // ref: https://vite.dev/config/shared-options#css-preprocessoroptions
        api: "modern-compiler", // or "modern"
        sourceMap: true,
      },
    },
  },
  optimizeDeps: {
    include: ["leaflet", "leaflet-control-geocoder", "screenfull"],
  },
});

Reproduction

#11612

Steps to reproduce

npm run dev

System Info

System:
    OS: macOS 14.4
    CPU: (10) arm64 Apple M2 Pro
    Memory: 81.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.12.0 - ~/.nvm/versions/node/v18.16.0/bin/pnpm
    bun: 1.0.1 - ~/.bun/bin/bun
    Watchman: 2024.10.28.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 126.1.67.119
    Chrome: 130.0.6723.119
    Edge: 131.0.2903.48
    Safari: 17.4
  npmPackages:
    @vitejs/plugin-react-swc: ^3.5.0 => 3.7.1 
    vite: ^5.4.10 => 5.4.11

Used Package Manager

npm

Logs

No response

Validations

Tasks

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

No branches or pull requests

1 participant