Skip to content

Commit

Permalink
chore: update configuration to create-plugin 5.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 1, 2024
1 parent 5c7449f commit a5c7a27
Show file tree
Hide file tree
Showing 5 changed files with 750 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .config/.cprc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "5.7.4"
"version": "5.10.0"
}
33 changes: 33 additions & 0 deletions .config/webpack/BuildModeWebpackPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as webpack from 'webpack';

const PLUGIN_NAME = 'BuildModeWebpack';

export class BuildModeWebpackPlugin {
apply(compiler: webpack.Compiler) {
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
async () => {
const assets = compilation.getAssets();
for (const asset of assets) {
if (asset.name.endsWith('plugin.json')) {
const pluginJsonString = asset.source.source().toString();
const pluginJsonWithBuildMode = JSON.stringify(
{
...JSON.parse(pluginJsonString),
buildMode: compilation.options.mode,
},
null,
4
);
compilation.updateAsset(asset.name, new webpack.sources.RawSource(pluginJsonWithBuildMode));
}
}
}
);
});
}
}
2 changes: 2 additions & 0 deletions .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { type Configuration, BannerPlugin } from 'webpack';
import LiveReloadPlugin from 'webpack-livereload-plugin';
import VirtualModulesPlugin from 'webpack-virtual-modules';

import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin';
import { DIST_DIR, SOURCE_DIR } from './constants';
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';

Expand Down Expand Up @@ -185,6 +186,7 @@ const config = async (env): Promise<Configuration> => {
},

plugins: [
new BuildModeWebpackPlugin(),
virtualPublicPath,
// Insert create plugin version information into the bundle
new BannerPlugin({
Expand Down
Loading

0 comments on commit a5c7a27

Please sign in to comment.