@@ -3,6 +3,7 @@ const exorcist = require("exorcist");
33const fs = require ( "node:fs" ) ;
44const path = require ( "node:path" ) ;
55const { minify } = require ( "terser" ) ;
6+ const { execSync } = require ( "node:child_process" ) ;
67
78const generateIndex = require ( "./generateIndex.js" ) ;
89const CL = require ( "./libs/ColorLogger.js" ) ;
@@ -43,7 +44,7 @@ function formatSize(bytes) {
4344// ファイルサイズ取得
4445function showFileSize ( filePath ) {
4546 const stat = fs . statSync ( filePath ) ;
46- console . log ( `📦 ${ CL . brightWhite ( path . basename ( filePath ) ) } : ${ CL . brightGreen ( formatSize ( stat . size ) ) } ` ) ;
47+ console . log ( `┃ 📦 ${ CL . brightWhite ( path . basename ( filePath ) ) } : ${ CL . brightGreen ( formatSize ( stat . size ) ) } ` ) ;
4748}
4849
4950// Browserifyでバンドル
@@ -95,28 +96,41 @@ async function minifyCode(code) {
9596}
9697
9798( async ( ) => {
99+ const debug = true ;
98100 try {
101+ const start = performance . now ( ) ;
102+ console . log ( `🎉 ${ CL . brightYellow ( "ビルド開始" ) } ` ) ;
99103 //
100- console . log ( `🔁 ${ CL . brightWhite ( "index.js自動生成開始..." ) } ` ) ;
104+ console . log ( `┣ 🔁 ${ CL . brightWhite ( "index.js自動生成開始..." ) } ` ) ;
101105 generateIndex ( entryDir ) ;
102- console . log ( `🌱 ${ CL . brightWhite ( "自動生成完了" ) } ` ) ;
106+ console . log ( `┃┗ 🌱 ${ CL . brightWhite ( "自動生成完了" ) } ` ) ;
103107 //
104- console . log ( `🗑️ ${ CL . brightWhite ( "distフォルダリセット" ) } ` ) ;
108+ console . log ( `┃ 🗑️ ${ CL . brightWhite ( "distフォルダリセット" ) } ` ) ;
105109 prepareDist ( ) ;
106110 //
107- console . log ( `🗂️ ${ CL . brightWhite ( "バンドル中..." ) } ` ) ;
111+ console . log ( `┃ 🗂️ ${ CL . brightWhite ( "バンドル中..." ) } ` ) ;
108112 const code = await bundle ( ) ;
109- console . log ( `✨ ${ CL . brightWhite ( "バンドル完了" ) } : ${ getRelativePath ( bundlePath ) } ` ) ;
110- console . log ( `🗺️ ${ CL . brightWhite ( "ソースマップ生成" ) } : ${ getRelativePath ( bundleMapPath ) } ` ) ;
111-
112- console . log ( `🔧 ${ CL . brightWhite ( "Minify中..." ) } ` ) ;
113+ console . log ( `┃┣✅ ${ CL . brightWhite ( "バンドル完了" ) } : ${ getRelativePath ( bundlePath ) } ` ) ;
114+ console . log ( `┃┗ 🗺️ ${ CL . brightWhite ( "ソースマップ生成" ) } : ${ getRelativePath ( bundleMapPath ) } ` ) ;
115+ //
116+ console . log ( `┃ 🔧 ${ CL . brightWhite ( "Minify中..." ) } ` ) ;
113117 await minifyCode ( code ) ;
114- console . log ( `✅ ${ CL . brightWhite ( "Minify完了:" ) } ${ getRelativePath ( minPath ) } ` ) ;
115- console . log ( `🗺️ ${ CL . brightWhite ( "ソースマップ生成[min]" ) } : ${ getRelativePath ( minMapPath ) } ` ) ;
118+ console . log ( `┃┣ ✅ ${ CL . brightWhite ( "Minify完了:" ) } ${ getRelativePath ( minPath ) } ` ) ;
119+ console . log ( `┃┗ 🗺️ ${ CL . brightWhite ( "ソースマップ生成[min]" ) } : ${ getRelativePath ( minMapPath ) } ` ) ;
116120 showFileSize ( bundlePath ) ;
117121 showFileSize ( minPath ) ;
122+ //
123+ if ( debug ) {
124+ console . log ( `┃🗒️ ${ CL . brightWhite ( "TypeScriptコンパイル中..." ) } ` ) ;
125+ execSync ( "npx tsc" , { stdio : "inherit" } ) ;
126+ console . log ( `┃┗✅ ${ CL . brightWhite ( "TypeScriptコンパイル完了" ) } ` ) ;
127+ }
128+
129+ console . log ( `┣🎉 ${ CL . brightYellow ( "ビルド完了" ) } ` ) ;
130+ const end = performance . now ( ) - start ;
131+ console . log ( `┗🕒 ${ CL . brightWhite ( "ビルド時間" ) } : ${ CL . brightGreen ( end . toFixed ( 2 ) ) } ms` ) ;
118132 } catch ( e ) {
119- console . error ( "❌ ビルド失敗:" , e ) ;
133+ console . error ( "┗ ❌ ビルド失敗:" , e ) ;
120134 process . exit ( 1 ) ;
121135 }
122136} ) ( ) ;
0 commit comments