File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,27 +104,32 @@ export function createImageOptimizerPlugin(options: ImageOptimizerOptions = {}):
104104 formats = [ "webp" , "jpeg" ] ,
105105 } = options ;
106106
107+ let isOptimized = false ;
108+
107109 return {
108110 name : "vitepress-image-optimizer" ,
109111
110- async buildStart ( ) {
111- console . log ( "🖼️ 이미지 최적화 시작..." ) ;
112+ async config ( ) {
113+ if ( ! isOptimized ) {
114+ console . log ( "🖼️ 이미지 최적화 시작..." ) ;
112115
113- try {
114- const imagePaths = await glob ( sourcePattern , {
115- cwd : process . cwd ( ) ,
116- absolute : true ,
117- } ) ;
116+ try {
117+ const imagePaths = await glob ( sourcePattern , {
118+ cwd : process . cwd ( ) ,
119+ absolute : true ,
120+ } ) ;
118121
119- console . log ( `📁 발견된 이미지: ${ imagePaths . length } 개` ) ;
122+ console . log ( `📁 발견된 이미지: ${ imagePaths . length } 개` ) ;
120123
121- for ( const imagePath of imagePaths ) {
122- await convertImage ( imagePath , formats , options ) ;
123- }
124+ for ( const imagePath of imagePaths ) {
125+ await convertImage ( imagePath , formats , options ) ;
126+ }
124127
125- console . log ( "✅ 이미지 최적화 완료!" ) ;
126- } catch ( error ) {
127- console . error ( "❌ 이미지 최적화 실패:" , error ) ;
128+ console . log ( "✅ 이미지 최적화 완료!" ) ;
129+ isOptimized = true ;
130+ } catch ( error ) {
131+ console . error ( "❌ 이미지 최적화 실패:" , error ) ;
132+ }
128133 }
129134 } ,
130135 } ;
You can’t perform that action at this time.
0 commit comments