@@ -30,12 +30,15 @@ if (fileSystem.existsSync(secretsPath)) {
3030
3131const options = [ 'manifest-v2' , 'manifest-v3' ] . map ( manifestVersion => {
3232 const outputDir = path . resolve ( __dirname , 'build' , manifestVersion )
33+ const test =
34+ NODE_ENV !== 'production' &&
35+ path . join ( __dirname , 'src' , 'pages' , 'Test' , 'index.ts' )
36+ const testEntry = test ? { test } : { }
3337 const option = {
3438 name : manifestVersion ,
3539 mode : NODE_ENV ,
3640 entry : {
3741 options : path . join ( __dirname , 'src' , 'pages' , 'Options' , 'index.tsx' ) ,
38- test : path . join ( __dirname , 'src' , 'pages' , 'Test' , 'index.ts' ) ,
3942 background : path . join ( __dirname , 'src' , 'pages' , 'Background' , 'index.ts' ) ,
4043 contentScript : path . join ( __dirname , 'src' , 'pages' , 'Content' , 'index.tsx' ) ,
4144 kitspaceContentScript : path . join (
@@ -46,6 +49,7 @@ const options = ['manifest-v2', 'manifest-v3'].map(manifestVersion => {
4649 'index.ts' ,
4750 ) ,
4851 popup : path . join ( __dirname , 'src' , 'pages' , 'Popup' , 'index.tsx' ) ,
52+ ...testEntry ,
4953 } ,
5054 output : {
5155 filename : '[name].bundle.js' ,
@@ -202,12 +206,6 @@ const options = ['manifest-v2', 'manifest-v3'].map(manifestVersion => {
202206 chunks : [ 'options' ] ,
203207 cache : false ,
204208 } ) ,
205- new HtmlWebpackPlugin ( {
206- template : path . join ( __dirname , 'src' , 'pages' , 'Test' , 'index.html' ) ,
207- filename : 'test.html' ,
208- chunks : [ 'test' ] ,
209- cache : false ,
210- } ) ,
211209 new HtmlWebpackPlugin ( {
212210 template : path . join ( __dirname , 'src' , 'pages' , 'Popup' , 'index.html' ) ,
213211 filename : 'popup.html' ,
@@ -229,7 +227,17 @@ const options = ['manifest-v2', 'manifest-v3'].map(manifestVersion => {
229227 } ) ,
230228 )
231229 }
232- if ( NODE_ENV === 'development' ) {
230+ if ( test ) {
231+ option . plugins . push (
232+ new HtmlWebpackPlugin ( {
233+ template : path . join ( __dirname , 'src' , 'pages' , 'Test' , 'index.html' ) ,
234+ filename : 'test.html' ,
235+ chunks : [ 'test' ] ,
236+ cache : false ,
237+ } ) ,
238+ )
239+ }
240+ if ( NODE_ENV !== 'production' ) {
233241 option . devtool = 'cheap-module-source-map'
234242 } else {
235243 option . optimization = {
0 commit comments