TouchMe
TouchMe
NNuxt
Created by TouchMe on 9/2/2024 in #❓・help
Nuxt 3 with Vite - Importing a Specific SCSS File Loads All SCSS Files in Development Mode
Hi everyone, I'm working on a project using Nuxt 3 with Vite, and I am facing an issue with dynamically importing SCSS files based on a variable. My goal is to import a specific SCSS file from the ~/assets directory, depending on the user's settings. However, when I use dynamic imports like this: javascript
import(`~/assets/theme/${theme}/${key}.scss`);
import(`~/assets/theme/${theme}/${key}.scss`);
It seems to import all SCSS files within the ~/assets/theme/ folder instead of just the specific file. This issue occurs in development mode, where Vite seems to preload or cache all files matching the path pattern. What I have tried so far: Setting build.modulePreload to false in vite.config.js, but it didn't change the behavior. Using the @vite-ignore directive, but it did not fully resolve the problem. Changing the folder structure and placing SCSS files in the public directory. This works to some extent, but I lose the benefits of SCSS processing (like variables and mixins). Questions: Is there a way to configure Vite to only load the specific SCSS file that matches the dynamic import path? Are there any plugins or custom middleware options that would help control how dynamic imports are handled in Vite when using Nuxt 3? Is there a recommended approach to dynamically load SCSS files without preloading all files in a folder during development? I'd appreciate any advice or solutions you might have! Thank you!
2 replies
NNuxt
Created by TouchMe on 5/5/2023 in #❓・help
FetchError: Failed to execute 'fetch' on 'Window': The user aborted a request.
anyone know the way to solve this error
1 replies
NNuxt
Created by TouchMe on 3/28/2023 in #❓・help
I don't want to rerender the page when changing the dynamic params on Nuxt
anyone help me
2 replies