Describe the bug
Similar to #2455, when importing SCSS into a JS file, with the ?url flag, the import will fail.
A related, but apparently different bug, is that if ?url is used with a CSS file, it evaluates to a string like export default "/src/style.css". This may deserve a separate issue.
Reproduction
This can be reproduced with:
yarn create @vitejs/app --template vue vite-sample; cd
yarn add sass
- Create
src/style.scss
- Add an import to
App.vue
import data from "./style.scss?url"
console.log(data)
Error in console
[plugin:vite:css] expected "{".
╷
1 │ export default "/src/style.scss"
│ ^
╵
src/style.scss 1:33 root stylesheet
/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/src/style.scss:1:33
at Object._newRenderError (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:13537:19)
at Object._wrapException (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:13374:16)
at _render_closure1.call$2 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:80373:21)
at _RootZone.runBinary$3$3 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:27269:18)
at _FutureListener.handleError$1 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:25797:19)
at _Future__propagateToListeners_handleError.call$0 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:26094:49)
at Object._Future__propagateToListeners (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:4543:77)
at _Future._completeError$2 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:25927:9)
at _AsyncAwaitCompleter.completeError$2 (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:25270:12)
at Object._asyncRethrow (/home/jonathan/src/git.ec2software.com/jonathan/vite-sample/node_modules/sass/sass.dart.js:4292:17
Click outside or fix the code to dismiss.
You can also disable this overlay with hmr: { overlay: false } in vite.config.js.
System Info
vite version: 2.1.0
- Operating System: Arch Linux
- Node version: v15.10.0
- Package manager (npm/yarn/pnpm) and version: yarn
Logs (Optional if provided reproduction)
- Run
vite or vite build with the --debug flag.
- Provide the error log here.
Describe the bug
Similar to #2455, when importing SCSS into a JS file, with the
?urlflag, the import will fail.A related, but apparently different bug, is that if
?urlis used with a CSS file, it evaluates to a string likeexport default "/src/style.css". This may deserve a separate issue.Reproduction
This can be reproduced with:
yarn create @vitejs/app --template vue vite-sample; cdyarn add sasssrc/style.scssApp.vueError in console
System Info
viteversion: 2.1.0Logs (Optional if provided reproduction)
viteorvite buildwith the--debugflag.