当前位置:   article > 正文

@use rules must be written before any other rules 报错_@use rules must be written before any other rules.

@use rules must be written before any other rules.
  1. export default defineConfig({
  2. plugins: [
  3. vue(),
  4. styleImport({
  5. libs: [
  6. {
  7. libraryName: 'element-plus',
  8. esModule: true,
  9. ensureStyleFile: true,
  10. resolveStyle: name => {
  11. name = name.slice(3)
  12. return `element-plus/packages/theme-chalk/src/${name}.scss`
  13. },
  14. resolveComponent: name => {
  15. return `element-plus/lib/${name}`
  16. },
  17. },
  18. ],
  19. }),
  20. ],
  21. css: {
  22. preprocessorOptions: {
  23. scss: {
  24. additionalData: `@import "@/theme/var.scss";`,
  25. },
  26. },
  27. },
  28. resolve: {
  29. alias: {
  30. '@': resolve('src'),
  31. },
  32. },
  33. })

使用了element-plus按需加载样式然后使用css.preprocessorOptions一起使用报错@use rules must be written before any other rules

解决方案如下:

  1. modules.exports = {
  2. ...
  3. css: {
  4. preprocessorOptions: {
  5. scss: {
  6. additionalData: `@use "@/theme/var.scss" as *;`,
  7. },
  8. },
  9. },
  10. ...
  11. }

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号