@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
50 lines (45 loc) • 1.3 kB
JavaScript
/**
* External Dependencies
*/
import { createRequire } from 'node:module';
const require = createRequire( import.meta.url );
const { mergeWithCustomize, customizeArray } = require( 'webpack-merge' );
const { BundleAnalyzerPlugin } = require( 'webpack-bundle-analyzer' );
/**
* Internal Dependencies
*/
import getConfig from '../../config.js';
import prodBase from './configs/prod-base.js';
import entry from './entry/theme.js';
import externals from './externals/theme/index.js';
import { scTheme } from './optimization/split-chunks.js';
const { config } = getConfig();
const pluginOverrides = Array.isArray( config.webpack?.overrides?.plugins?.release?.theme )
? config.webpack.overrides.plugins.release.theme
: [];
export default mergeWithCustomize( {
customizeArray: customizeArray( {
optimization: 'append',
plugins: 'append',
} ),
} )(
prodBase,
{
entry,
externals,
optimization: {
splitChunks: config?.webpack?.overrides?.optimization?.splitChunks?.scTheme || scTheme,
},
output: {
path: config.paths.js_dist,
},
plugins: [
...pluginOverrides,
new BundleAnalyzerPlugin( {
analyzerMode: 'static',
reportFilename: config?.paths?.reports?.replace( '%s', 'theme-bundle-prod' ) || 'theme-bundle-prod',
openAnalyzer: false,
} ),
],
}
);