@@ -7,6 +7,36 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin'
77import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
88import { EsbuildPlugin } from 'esbuild-loader'
99
10+ let active_compilers = 0
11+
12+ const build_status_plugin = {
13+ apply ( compiler : webpack . Compiler ) {
14+ let is_initial_build = true
15+
16+ const on_start = ( ) => {
17+ if ( is_initial_build ) {
18+ if ( active_compilers === 0 ) {
19+ console . log ( 'Building...' )
20+ }
21+ active_compilers ++
22+ }
23+ }
24+
25+ compiler . hooks . run . tap ( 'BuildStatusPlugin' , on_start )
26+ compiler . hooks . watchRun . tap ( 'BuildStatusPlugin' , on_start )
27+
28+ compiler . hooks . done . tap ( 'BuildStatusPlugin' , ( ) => {
29+ if ( is_initial_build ) {
30+ active_compilers --
31+ if ( active_compilers === 0 ) {
32+ console . log ( 'Done' )
33+ }
34+ is_initial_build = false
35+ }
36+ } )
37+ }
38+ }
39+
1040const config : ( ( env : any , argv : any ) => webpack . Configuration ) [ ] = [
1141 // Extension Configuration (Node.js environment)
1242 ( env : any , argv : any ) : webpack . Configuration => {
@@ -67,20 +97,25 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
6797 ]
6898 } ,
6999 plugins : [
100+ build_status_plugin ,
70101 new CleanWebpackPlugin ( {
71102 cleanOnceBeforeBuildPatterns : [ '../*.vsix' ] ,
72103 dangerouslyAllowCleanPatternsOutsideProject : true ,
73104 dry : false
74105 } ) ,
75- new ForkTsCheckerWebpackPlugin ( {
76- typescript : {
77- configFile : path . resolve ( __dirname , 'tsconfig.json' ) ,
78- diagnosticOptions : {
79- semantic : true ,
80- syntactic : true
81- }
82- }
83- } ) ,
106+ ...( argv . watch
107+ ? [ ]
108+ : [
109+ new ForkTsCheckerWebpackPlugin ( {
110+ typescript : {
111+ configFile : path . resolve ( __dirname , 'tsconfig.json' ) ,
112+ diagnosticOptions : {
113+ semantic : true ,
114+ syntactic : true
115+ }
116+ }
117+ } )
118+ ] ) ,
84119 new CopyWebpackPlugin ( {
85120 patterns : [
86121 {
@@ -108,10 +143,10 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
108143 } ,
109144 // View Configuration (Web environment)
110145 ( env : any , argv : any ) : webpack . Configuration => {
111- const isProduction = argv . mode === 'production'
146+ const is_production = argv . mode === 'production'
112147 return {
113148 name : 'view' ,
114- mode : isProduction ? 'production' : 'development' ,
149+ mode : is_production ? 'production' : 'development' ,
115150 target : 'web' ,
116151 entry : {
117152 prompt : './src/views/prompt/frontend/App.tsx' ,
@@ -126,7 +161,7 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
126161 performance : {
127162 hints : false
128163 } ,
129- devtool : isProduction ? false : 'eval-cheap-module-source-map' ,
164+ devtool : is_production ? false : 'eval-cheap-module-source-map' ,
130165 optimization : {
131166 minimizer : [
132167 new EsbuildPlugin ( {
@@ -166,23 +201,23 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
166201 getLocalIdent : (
167202 context : webpack . LoaderContext < any > ,
168203 _ : any ,
169- localName : string
204+ local_name : string
170205 ) => {
171206 const filename = context . resourcePath
172- const isModule = / \. m o d u l e \. ( s c s s | c s s ) $ / i. test ( filename )
173- if ( isModule ) {
174- const moduleName = path
207+ const is_module = / \. m o d u l e \. ( s c s s | c s s ) $ / i. test ( filename )
208+ if ( is_module ) {
209+ const module_name = path
175210 . basename ( filename as string )
176211 . replace ( / \. m o d u l e \. ( s c s s | c s s ) $ / i, '' )
177212 const hash = crypto
178213 . createHash ( 'md5' )
179- . update ( `${ filename } ${ localName } ` )
214+ . update ( `${ filename } ${ local_name } ` )
180215 . digest ( 'hex' )
181216 . substring ( 0 , 5 )
182- return `${ moduleName } __${ localName } __${ hash } `
217+ return `${ module_name } __${ local_name } __${ hash } `
183218 }
184219 // Return original name for non-module files
185- return localName
220+ return local_name
186221 }
187222 } ,
188223 importLoaders : 1
@@ -222,6 +257,7 @@ const config: ((env: any, argv: any) => webpack.Configuration)[] = [
222257 ]
223258 } ,
224259 plugins : [
260+ build_status_plugin ,
225261 new MiniCssExtractPlugin ( {
226262 filename : '[name].css'
227263 } ) as unknown as webpack . WebpackPluginInstance
0 commit comments