feat: upgrade to Vite v5

This commit is contained in:
JellyBrick
2023-12-18 21:10:47 +09:00
parent 53ac7ff257
commit e0eeb720cd
7 changed files with 49 additions and 30 deletions

View File

@ -1,4 +1,5 @@
import { basename, relative, resolve, extname } from 'node:path';
import { basename, relative, resolve, extname, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { globSync } from 'glob';
import { Project } from 'ts-morph';
@ -7,6 +8,7 @@ const snakeToCamel = (text: string) =>
text.replace(/-(\w)/g, (_, letter: string) => letter.toUpperCase());
export const i18nImporter = () => {
const __dirname = dirname(fileURLToPath(import.meta.url));
const project = new Project({
tsConfigFilePath: resolve(__dirname, '..', 'tsconfig.json'),
skipAddingFilesFromTsConfig: true,

View File

@ -1,4 +1,5 @@
import { basename, relative, resolve, extname } from 'node:path';
import { basename, relative, resolve, extname, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { globSync } from 'glob';
import { Project } from 'ts-morph';
@ -9,6 +10,7 @@ const snakeToCamel = (text: string) =>
export const pluginVirtualModuleGenerator = (
mode: 'main' | 'preload' | 'renderer',
) => {
const __dirname = dirname(fileURLToPath(import.meta.url));
const project = new Project({
tsConfigFilePath: resolve(__dirname, '..', 'tsconfig.json'),
skipAddingFilesFromTsConfig: true,

View File

@ -1,5 +1,6 @@
import { readFile } from 'node:fs/promises';
import { resolve, basename } from 'node:path';
import { resolve, basename, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { createFilter } from 'vite';
import { Project, ts, ObjectLiteralExpression, VariableDeclarationKind } from 'ts-morph';
@ -17,6 +18,8 @@ export default function (mode: 'backend' | 'preload' | 'renderer' | 'none'): Plu
async load(id) {
if (!pluginFilter(id)) return null;
const __dirname = dirname(fileURLToPath(import.meta.url));
const project = new Project({
tsConfigFilePath: resolve(__dirname, '..', 'tsconfig.json'),
skipAddingFilesFromTsConfig: true,