Skip to content

Commit

Permalink
parameterize plugin configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Jul 1, 2024
1 parent 38be6a9 commit e1c912f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/plugins/dir2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Dirent, existsSync, promises as fs } from "node:fs";
import path from "node:path";
import { type PluginOption, normalizePath } from "vite";

export default (): PluginOption => {
export default ({ includes }: { includes: string[] }): PluginOption => {
return {
name: "dir-as-json",

Expand Down Expand Up @@ -43,7 +43,7 @@ export default (): PluginOption => {
const [parentPath, entries] = dirEntries.pop()!;
const absoluteParentPath = path.join(dirPath, parentPath);
promises.push(...entries.map(async (entry) => {
if (entry.isFile() && !entry.name.endsWith(".pyi") && !entry.name.endsWith(".d.ts")) {
if (entry.isFile() && includes.some(ext => entry.name.endsWith(ext))) {
const filePath = path.join(absoluteParentPath, entry.name);
this.addWatchFile(filePath);
const relativePath = path.relative(dirPath, filePath);
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import Unocss from "unocss/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [Unocss(), sveltekit(), dir2json()],
plugins: [Unocss(), sveltekit(), dir2json({ includes: ["py", "j2"] })],
assetsInclude: ["src/python/**/*"],
});

0 comments on commit e1c912f

Please sign in to comment.