File tree Expand file tree Collapse file tree 5 files changed +25
-6
lines changed Expand file tree Collapse file tree 5 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ export class CreateWebpackConfig {
172172 tsBabelOverride,
173173 tsBabelPresetOptions,
174174 useReactJsxRuntime,
175+ disableWordPressExternals,
175176 } = this . projectConfig ;
176177 const { host, port } = this . serverConfig ;
177178 const helper : WebpackConfigHelper = new WebpackConfigHelper (
@@ -201,6 +202,7 @@ export class CreateWebpackConfig {
201202 tsBabelOverride,
202203 tsBabelPresetOptions,
203204 useReactJsxRuntime,
205+ disableWordPressExternals,
204206 } ,
205207 this . cwd ,
206208 this . isDev
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ export interface WebpackConfigHelperConfig {
5959 publicPathUrl : string ;
6060 errorOverlay : ProjectConfig [ 'errorOverlay' ] ;
6161 externals : ProjectConfig [ 'externals' ] ;
62+ // whether or not to disable wordpress external scripts handling
63+ disableWordPressExternals ?: boolean ;
6264}
6365
6466interface CommonWebpackConfig {
@@ -325,12 +327,14 @@ export class WebpackConfigHelper {
325327 }
326328
327329 // Add wordpress dependency extract plugin
328- plugins . push (
329- new DependencyExtractionWebpackPlugin ( {
330- gutenbergOptimized : this . file . optimizeForGutenberg ?? false ,
331- appDir : this . appDir ,
332- } )
333- ) ;
330+ if ( this . config . disableWordPressExternals !== true ) {
331+ plugins . push (
332+ new DependencyExtractionWebpackPlugin ( {
333+ gutenbergOptimized : this . file . optimizeForGutenberg ?? false ,
334+ appDir : this . appDir ,
335+ } )
336+ ) ;
337+ }
334338
335339 // Add development specific plugins
336340 if ( this . isDev ) {
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ export interface ProjectConfig {
100100 packageFiles : string [ ] ;
101101 packageDirPath : string ;
102102 zlibLevel ?: number ;
103+ // whether or not to disable wordpress external scripts handling
104+ disableWordPressExternals ?: boolean ;
103105}
104106
105107/**
@@ -187,4 +189,6 @@ export const projectConfigDefault: ProjectConfig = {
187189 packageDirPath : 'package' ,
188190 // Level of zlib compression, when creating archive
189191 zlibLevel : 4 ,
192+ // whether or not to disable wordpress external scripts handling
193+ disableWordPressExternals : false ,
190194} ;
Original file line number Diff line number Diff line change @@ -96,4 +96,6 @@ module.exports = {
9696 ],
9797 // Path to package directory, relative to the root
9898 packageDirPath: 'package',
99+ // whether or not to disable wordpress external scripts handling
100+ disableWordPressExternals: false,
99101};
Original file line number Diff line number Diff line change @@ -428,3 +428,10 @@ The generated package file will also have name like `<slug>.zip`.
428428## zlibLevel (` number ` )
429429
430430The level of zlib compression to use when creating the zip.
431+
432+ ## disableWordPressExternals (` boolean ` )
433+
434+ Whether or not to disable wordpress external scripts handling. If this option
435+ is set to true, then no ` @wordpress ` name-spaced dependencies will be extracted
436+ as an external. Also the dependencies json file which the PHP library depends on
437+ (but will not fail if is not present) will not be created.
You canβt perform that action at this time.
0 commit comments