Scss async import fails in built app, works in dev server
See original GitHub issueDescribe the bug
Minimal reproduction: https://github.com/ilyary/hyve-gtm
Fails to import like this: import(“@/styles/async.scss”);
<template>
<NuxtPage />
</template>
<script>
import "bootstrap/scss/bootstrap.scss";
//import "@/styles/async.scss"; // That works
import("@/styles/xxx.js"); // That works
import("@/styles/async.scss"); // Not working
/*
>npm run generate
...
ℹ Initializing prerenderer
ERROR Rollup error: Could not resolve './_nuxt/async.744a712b.js' from .nuxt/dist/server/server.mjs nitro 09:45:18
ERROR Could not resolve './_nuxt/async.744a712b.js' from .nuxt/dist/server/server.mjs 09:45:18
at error (node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at ModuleLoader.handleResolveId (node_modules/rollup/dist/es/shared/rollup.js:22357:24)
at ModuleLoader.resolveDynamicImport (node_modules/rollup/dist/es/shared/rollup.js:22411:120)
at async node_modules/rollup/dist/es/shared/rollup.js:22306:32
*/
</script>
Very similar to https://github.com/vitejs/vite/issues/1694
Reproduction
n/a
System Info
latest nuxt3, vite@3.0.9
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Loading an async component fails in built app, ...
Reproduction. Not sure how to reproduce. Repository is a company project I am trying to migrate to use Vite. Relevant config file: import...
Read more >Import scss file is not working inside storybook file
If this doesn't work, try importing your scss file in preview.js of storybook config folder. .storybook > preview.js > import your CSS file;....
Read more >How To Handle Async Data Loading, Lazy Loading, and ...
Now you need to import and render the new component to your root component. Open App.js : nano src/components/App/App.js.
Read more >sass-loader - webpack - JS.ORG
"modern" API is experimental, so some features may not work (known: built-in importer is not working and files with errors is not watching...
Read more >4 Reasons Why You Should Prefer Vite Over Create-React ...
Unlike CRA, Vite does not build your entire application before serving, instead, it builds the application on demand.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
true, it works on npm create vite@latest my-vue-app – --template vue npm i -D sass sass-loader
so, then it’s probably nuxt or sass bug, or both))
Probably not vite issue