nuxt.js引入scss文件,变量Undefined variable

在nuxt.config.js中使用styleResources引入公共scss文件,变量报错

error  in ./layouts/default.vue?vue&type=style&index=0&id=314f53c6&lang=scss&scoped=true&

Module build failed (from ./node_modules/sass-loader/lib/loader.js):

undefined
               ^
      Undefined variable: "$white".
      in e:\Vue\blog-nuxt\layouts\default.vue (line 84, column 17)

 @ ./node_modules/vue-style-loader??ref--6-oneOf-1-0!./node_modules/css-loader??ref--6-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--6-oneOf-1-2!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-1-3!./node_modules/style-resources-loader/lib??ref--6-oneOf-1-4!./node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=style&index=0&id=314f53c6&lang=scss&scoped=true& 4:14-462 14:3-18:5 15:22-470
 @ ./layouts/default.vue?vue&type=style&index=0&id=314f53c6&lang=scss&scoped=true&
 @ ./layouts/default.vue
 @ ./.nuxt/App.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=/__webpack_hmr ./.nuxt/client.js

nuxt.js引入scss文件,变量Undefined variable

开始是node升级node11.0导致的node-sass或sass-loader版本过低的问题

最后可能nuxt.js升级到2.0后,styleResources引用路径不能使用~。把~换成./后,引用成功,报错解决

nuxt.js引入scss文件,变量Undefined variable

相关推荐