Skip to content

Commit

Permalink
Extend project root config only if file exists (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
stian-overasen authored Oct 17, 2024
1 parent 890c1f9 commit 48c064d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/themes/block-theme/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
*/
const { sync: globSync } = require('fast-glob');
const path = require('path');
const fs = require('fs');

/**
* WordPress dependencies
*/
const { getWebpackEntryPoints } = require('@wordpress/scripts/utils/config');
let scriptConfig = require('@wordpress/scripts/config/webpack.config');

/**
* Internal dependencies
*/
const rootConfig = require('../../../webpack.config');
if (fs.existsSync('../../../webpack.config.js')) {
// Extend project root config if exists.
scriptConfig = require('../../../webpack.config');
}

function getPackageEntryPoints() {
// Use default entry points from wp-scripts.
Expand All @@ -29,6 +34,6 @@ function getPackageEntryPoints() {
}

module.exports = {
...rootConfig,
...scriptConfig,
entry: getPackageEntryPoints(),
};

0 comments on commit 48c064d

Please sign in to comment.