最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - How to have named imports and custom file names with Vite, React, Typescript and SCCS modules - Stack Overflow

programmeradmin1浏览0评论

I have a Vite/React/Typescript app configured with sass and I would like to:

  1. Import the styles as named imports:
import { styles } from "my-component.styles.scss";
  1. Configure Vite (or sass) to recognize all *.styles.scss files as css modules as it happens for *.modules.scss

Here is my Vite config file

/// <reference types="vitest" />
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { defineConfig } from "vite";

// /config/
export default defineConfig({
  plugins: [react()],
  },
  css: {
    preprocessorOptions: {
      scss: {
        api: "modern-compiler"
      }
    },
    modules: {
      localsConvention: "camelCase"
    }
  }
});

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论