From 7bd0a5b7cb9d89abe750051d27fec447c0792a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:31:01 +0900 Subject: [PATCH] (refactor) do generateDTS in build-assets (#11812) --- locales/generateDTS.js | 7 ++++++- packages/frontend/vite.config.ts | 5 ----- scripts/build-assets.mjs | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/locales/generateDTS.js b/locales/generateDTS.js index 7369dfbb4..7af773f3b 100644 --- a/locales/generateDTS.js +++ b/locales/generateDTS.js @@ -1,6 +1,11 @@ import * as fs from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; import * as yaml from 'js-yaml'; -import * as ts from 'typescript'; +import ts from 'typescript'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); function createMembers(record) { return Object.entries(record) diff --git a/packages/frontend/vite.config.ts b/packages/frontend/vite.config.ts index 531dd0b48..7c5970554 100644 --- a/packages/frontend/vite.config.ts +++ b/packages/frontend/vite.config.ts @@ -6,7 +6,6 @@ import { type UserConfig, defineConfig } from 'vite'; import ReactivityTransform from '@vue-macros/reactivity-transform/vite'; import locales from '../../locales'; -import generateDTS from '../../locales/generateDTS'; import meta from '../../package.json'; import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name'; import pluginJson5 from './vite.json5'; @@ -67,10 +66,6 @@ export function getConfig(): UserConfig { }), ] : [], - { - name: 'locale:generateDTS', - buildStart: generateDTS, - }, ], resolve: { diff --git a/scripts/build-assets.mjs b/scripts/build-assets.mjs index 9e411fe86..a8a2cafa5 100644 --- a/scripts/build-assets.mjs +++ b/scripts/build-assets.mjs @@ -10,6 +10,7 @@ import postcss from 'postcss'; import * as terser from 'terser'; import locales from '../locales/index.js'; +import generateDTS from '../locales/generateDTS.js'; import meta from '../package.json' assert { type: "json" }; async function copyFrontendFonts() { @@ -21,6 +22,8 @@ async function copyFrontendTablerIcons() { } async function copyFrontendLocales() { + generateDTS(); + await fs.mkdir('./built/_frontend_dist_/locales', { recursive: true }); const v = { '_version_': meta.version };