question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scss async import fails in built app, works in dev server

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ilyarycommented, Sep 19, 2022

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))

0reactions
ilyarycommented, Sep 19, 2022

Probably not vite issue

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found