SassError: Can't find stylesheet to import when it contains @forward with _index file
See original GitHub issueDescribe the bug
10:13:27 AM [vite] Internal server error: Can't find stylesheet to import.
╷
1 │ @use "@material/chips/mdc-chips";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src/styles/index.scss 1:1 @import
src/App.vue 3:9 root stylesheet
Plugin: vite:css
File: /Users/***/styles/index.scss
Error: Can't find stylesheet to import.
╷
1 │ @use "@material/chips/mdc-chips";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
The _index.scss of this dep contains @forward rules.
More information:
There is the same problem in webpack, but can be solved like this, but I haven’t see options like this in Vite’s documentation.
Reproduction
yarn add @material/chips@canary- In a new Vue3 template project.
@usethe dep’s style following documentation:
<style lang="scss">
@use "@material/chips/mdc-chips";
</style>
System Info
System:
OS: macOS 11.4
CPU: (4) x64 Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
Memory: 73.38 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
Browsers:
Chrome: 91.0.4472.114
Firefox: 89.0.1
Safari: 14.1.1
npmPackages:
@vitejs/plugin-vue: ^1.2.4 => 1.2.4
vite: ^2.3.8 => 2.3.8
Used Package Manager
yarn
Logs
yarn run v1.22.10
$ vite build --debug
vite:config bundled config file loaded in 220ms +0ms
vite:config using resolved config: {
vite:config base: 'http://localhost:9000/',
vite:config resolve: { dedupe: undefined, alias: [ [Object], [Object], [Object] ] },
vite:config plugins: [
vite:config 'alias',
vite:config 'svgicon',
vite:config 'vite:dynamic-import-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:vue',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'rollup-plugin-dynamic-import-variables',
vite:config 'vite:import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:manifest',
vite:config 'vite:reporter'
vite:config ],
vite:config server: {
vite:config host: '0.0.0.0',
vite:config cors: true,
vite:config strictPort: true,
vite:config port: 9000,
vite:config hmr: { protocol: 'ws', host: 'localhost', port: 9000 },
vite:config fsServe: { root: '/Users/****/wd/****', strict: false }
vite:config },
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillDynamicImport: false,
vite:config outDir: 'app/assets/dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config sourcemap: true,
vite:config rollupOptions: {},
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config minify: 'terser',
vite:config terserOptions: {},
vite:config cleanCssOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: true,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config brotliSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null
vite:config },
vite:config css: { preprocessorOptions: { scss: [Object] } },
vite:config define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
vite:config ssr: { external: [ 'vue', '@vue/server-renderer' ] },
vite:config configFile: '/Users/****/wd/****/vite.config.ts',
vite:config configFileDependencies: [ 'vite.config.ts' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config build: {}
vite:config },
vite:config root: '/Users/****/wd/****',
vite:config publicDir: '/Users/****/wd/****/public',
vite:config cacheDir: '/Users/****/wd/****/node_modules/.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config isProduction: true,
vite:config env: {
vite:config BASE_URL: 'http://localhost:9000/',
vite:config MODE: 'production',
vite:config DEV: false,
vite:config PROD: true
vite:config },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen]
vite:config },
vite:config createResolver: [Function: createResolver],
vite:config optimizeDeps: { esbuildOptions: { keepNames: undefined } }
vite:config } +7ms
vite v2.3.8 building for production...
transforming (69) node_modules/camelcase-keys/index.js vite:resolve 0ms /src//styles/mixins/skeleton -> /Users/****/wd/****/src/styles/mixins/_skeleton.scss +0ms
vite:resolve 0ms @/styles/mixins/skeleton -> /Users/****/wd/****/src/styles/mixins/_skeleton.scss +0ms
vite:resolve 22ms /src//styles/index.scss -> /Users/****/wd/****/src/styles/index.scss +415ms
vite:resolve 23ms @/styles/index.scss -> /Users/****/wd/****/src/styles/index.scss +1ms
transforming (80) node_modules/@vue/devtools-api/lib/esm/api/index.js vite:resolve 3ms @material/chips/mdc-chips -> null +200ms
✓ 95 modules transformed.
[vite:css] Can't find stylesheet to import.
╷
1 │ @use "@material/chips/mdc-chips";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src/styles/index.scss 1:1 @import
src/App.vue 3:9 root stylesheet
file: /Users/****/wd/****/src/App.vue?vue&type=style&index=0&lang.scss
Error: Can't find stylesheet to import.
╷
1 │ @use "@material/chips/mdc-chips";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src/styles/index.scss 1:1 @import
src/App.vue 3:9 root stylesheet
error during build:
Error: Can't find stylesheet to import.
╷
1 │ @use "@material/chips/mdc-chips";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src/styles/index.scss 1:1 @import
src/App.vue 3:9 root stylesheet
at Object._newRenderError (/Users/****/wd/****/node_modules/sass/sass.dart.js:13222:19)
at Object._wrapException (/Users/****/wd/****/node_modules/sass/sass.dart.js:13050:16)
at _render_closure1.call$2 (/Users/****/wd/****/node_modules/sass/sass.dart.js:81775:21)
at _RootZone.runBinary$3$3 (/Users/****/wd/****/node_modules/sass/sass.dart.js:27547:18)
at _FutureListener.handleError$1 (/Users/****/wd/****/node_modules/sass/sass.dart.js:26096:19)
at _Future__propagateToListeners_handleError.call$0 (/Users/****/wd/****/node_modules/sass/sass.dart.js:26394:49)
at Object._Future__propagateToListeners (/Users/****/wd/****/node_modules/sass/sass.dart.js:4541:77)
at _Future._completeError$2 (/Users/****/wd/****/node_modules/sass/sass.dart.js:26226:9)
at _AsyncAwaitCompleter.completeError$2 (/Users/****/wd/****/node_modules/sass/sass.dart.js:25880:12)
at Object._asyncRethrow (/Users/****/wd/****/node_modules/sass/sass.dart.js:4340:17)
error Command failed with exit code 1.
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 https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Sass "Error: Can't find stylesheet to import." - Stack Overflow
I solved it by using an extra forward slash @import ... You might not need this configuration if the index file is in...
Read more >SassError: Can't find stylesheet to import when it contains ...
sass-loader throws following error when @import 'ed Sass file contain @forward statement with _index file. (See reproducible steps below).
Read more >Executing Sass - Can't find stylesheet to import - Syncfusion
However, when I want to execute sass on this file (let's call it button.scss), it throws an error: Error: Can't find stylesheet to...
Read more >Sass: @use
A stylesheet's @use rules must come before any rules other than @forward , including style ... That means stylesheets that load your module...
Read more >Sass Error after upgrading vom v14 to v15 | Infragistics Forums
SassError : Can't find stylesheet to import. ... 7:1 @forward @infragistics\igniteui-angular\_index.scss 1:1 @use
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
here, https://github.com/mashirozx/sakura/blob/next/src/admin/_mdc.scss
We stooped using
˜because vite does not come with that alias out of the box like vue-cli did.So we have refactored our code.
Instead of using:
we are using:
EDIT: Looking at the repo I think our problem was this: https://stackblitz.com/edit/vitejs-vite-fw386x?file=src%2FApp.scss&terminal=dev but again with @ or node_modules it works fine