From 3fb645025b002de32d9c920129ba053937e0c14f Mon Sep 17 00:00:00 2001 From: tai-cha Date: Mon, 17 Feb 2025 18:49:11 +0900 Subject: [PATCH] =?UTF-8?q?=E9=96=8B=E7=99=BA=E3=82=B5=E3=83=BC=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=81=A7=E3=81=A0=E3=81=91=E5=BF=85=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E6=8C=99=E5=8B=95=E3=81=AF=E9=96=8B=E7=99=BA=E3=82=B5=E3=83=BC?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=81=AE=E3=81=BF=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/lib/vite-plugin-create-search-index.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/frontend/lib/vite-plugin-create-search-index.ts b/packages/frontend/lib/vite-plugin-create-search-index.ts index 33f34e2818..946c903c8b 100644 --- a/packages/frontend/lib/vite-plugin-create-search-index.ts +++ b/packages/frontend/lib/vite-plugin-create-search-index.ts @@ -67,7 +67,6 @@ export type ComponentUsageInfo = AnalysisResults[number]['usage'][number]; try { fs.writeFileSync(outputPath, tsOutput, 'utf-8'); - console.log(`[create-search-index]: output done. ${outputPath}`); } catch (error) { console.error('[create-search-index]: error: ', error); } @@ -214,20 +213,23 @@ export default function pluginCreateSearchIndex(options: { exportFilePath: string }): Plugin { let transformedCodeCache: Record = {}; // ★ キャッシュオブジェクトをプラグインスコープで定義 + const isDevServer = process.env.NODE_ENV === 'development'; // 開発サーバーかどうか return { name: 'createSearchIndex', enforce: 'pre', async buildStart() { - transformedCodeCache = {}; + if (isDevServer) { + return; + } const filePaths = options.targetFilePaths.reduce((acc, filePathPattern) => { const matchedFiles = glob.sync(filePathPattern); return [...acc, ...matchedFiles]; }, []); - for (const filePath of filePaths) { // ★ 全ファイルパスに対して処理を実行 + for (const filePath of filePaths) { const id = path.resolve(filePath); // 絶対パスに変換 const code = fs.readFileSync(filePath, 'utf-8'); // ファイル内容を読み込む await processVueFile(code, id, options, transformedCodeCache); // processVueFile 関数を呼び出す @@ -262,10 +264,11 @@ export default function pluginCreateSearchIndex(options: { if (!isMatch) { return null; } - console.log(`[create-search-index] transform: Processing file: ${id}`); // ログ: transform で処理中のファイル const transformed = await processVueFile(code, id, options, transformedCodeCache); - await analyzeVueProps({ ...options, transformedCodeCache }); // analyzeVueProps を呼び出す + if (isDevServer) { + await analyzeVueProps({ ...options, transformedCodeCache }); // analyzeVueProps を呼び出す + } return transformed; },