1.0.20 • Published 1 year ago

ts-css-modules-vite-plugin v1.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ts-css-modules-vite-plugin

Read the definition of vite.config.ts and resolve the CSS Modules type. Supports sass.

Demo

Install

npm i -D ts-css-modules-vite-plugin

Options

ParameterTypeDescription
rootstringSet the relative path from the project root to the 'vite.config.ts' file. (default ./)

Add it to the tsconfig.json

{
  "compilerOptions": {
    ...
    "plugins": [{"name": "ts-css-modules-vite-plugin", "root": "./"}]
  },
}

Resolve the vite.config.ts

Resolve the preprocessorOptions setting within the plugin.

import path from "path";
import { defineConfig } from "vite";

export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles" as common;`,
        importer(...args) {
          if (args[0] !== "@/styles") {
            return;
          }

          return {
            file: `${path.resolve(__dirname, "./src/assets/styles")}`,
          };
        },
      },
    },
  },
});

Using VS Code

The VScode typescript version needs to match the project. Set the following.

{
  "typescript.tsdk": "node_modules/typescript/lib"
}

Use the workspace version. スクリーンショット 2022-12-23 23 20 51

1.0.19

1 year ago

1.0.20

1 year ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago