Skip to content

Commit

Permalink
feat!: make opts.pattern required (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
koyashiro authored Jun 3, 2024
1 parent 007d7ed commit ec3bf16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ import { defineConfig } from "vite";
import happyCssModules from "vite-plugin-happy-css-modules";

export default defineConfig({
plugins: [happyCssModules()],
plugins: [happyCssModules({ pattern: "src/**/*.module.{css,scss,less}" })],
});
```
10 changes: 2 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { run } from "happy-css-modules";
import type { Plugin } from "vite";

const DEFAULT_PATTERN = "**/*.module.{css,scss,less}";
export type Options = Omit<Parameters<typeof run>[0], "watch">;

export type Options = Omit<Parameters<typeof run>[0], "pattern" | "watch"> & {
pattern?: string;
};

export default function happyCssModules(opts?: Options): Plugin {
const pattern = opts?.pattern ?? DEFAULT_PATTERN;
export default function happyCssModules(opts: Options): Plugin {
const declarationMap = opts?.declarationMap ?? true;

const runnerOptions = {
pattern,
watch: false,
declarationMap,
...opts,
Expand Down

0 comments on commit ec3bf16

Please sign in to comment.