Vite: scss import error

Created on 17 Jul 2020  路  3Comments  路  Source: vitejs/vite

Do NOT ignore this template or your issue will have a very high chance to be closed without comment.

Describe the bug

When I upgraded to version 1.0.0-beta.12, there was a problem with scss import

Reproduction

Please provide a link to a repo that can reproduce the problem you ran into.

A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.

System Info

  • required vite version: 1.0.0-beta.12
  • required Operating System: macOs 10.15.6
  • required Node version: v10.16.2
  • Optional:

    • npm/yarn version

    • Installed vue version (from yarn.lock or package-lock.json)

    • Installed @vue/compiler-sfc version

Logs (Optional if provided reproduction)

import point

// main.ts
import './styles/reset.scss';
import './styles/global.scss';

// or App.vue
<style lang="scss">
@import './styles/reset.scss';
@import './styles/global.scss';
</style>

bash error

  vite:rewrite /: serving from cache +1m
  vite:rewrite (skipped) / +1m
  vite:rewrite (cached) /src/main.ts +82ms
  vite:rewrite (skipped) /vite/hmr +109ms
  vite:resolve (cached) vue.js -> node_modules/.vite_opt_cache/vue.js +1m
  vite:rewrite (cached) /@modules/vue.js +6ms
  vite:resolve (cached) dynamic-import-polyfill/dist/dynamic-import-polyfill.mjs -> node_modules/dynamic-import-polyfill/dist/dynamic-import-polyfill.mjs +8ms
  vite:rewrite (cached) /@modules/dynamic-import-polyfill/dist/dynamic-import-polyfill.mjs +7ms

  TypeError: Cannot read property 'forEach' of undefined
      at Object.recordCssImportChain (/Users/meicai/Documents/workspace/kf-fe/h5/node_modules/vite/dist/node/utils/cssUtils.js:154:18)
      at processCss (/Users/meicai/Documents/workspace/kf-fe/h5/node_modules/vite/dist/node/server/serverPluginCss.js:129:20)

  vite:sfc /Users/meicai/Documents/workspace/kf-fe/h5/src/App.vue parse cache hit +1m
  vite:rewrite (cached) /@/App.vue +31ms

  TypeError: Cannot read property 'forEach' of undefined
      at Object.recordCssImportChain (/Users/meicai/Documents/workspace/kf-fe/h5/node_modules/vite/dist/node/utils/cssUtils.js:154:18)
      at processCss (/Users/meicai/Documents/workspace/kf-fe/h5/node_modules/vite/dist/node/server/serverPluginCss.js:129:20)

  vite:rewrite (cached) /@/init.ts +106ms
  vite:rewrite (cached) /@/utils/request.ts +1ms
  vite:rewrite (cached) /@/router/index.ts +7ms
  vite:hmr ws client connected +1m
  vite:rewrite (cached) /@/store/index.ts +24ms
  vite:rewrite (skipped) /favicon.ico +352ms
  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
pending triage

All 3 comments

I test it and it worked fine. Can you provider an git repo for this?

It happened with @vue/compiler-sfc 3.0.0-beta.22.
Updating it to 3.0.0-beta.24 fixed for me.

Yeah.It need upgrade.I close this because it's not a bug.

Was this page helpful?
0 / 5 - 0 ratings