@grafana/create-plugin 5.7.5 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v5.8.0 (Fri Nov 01 2024)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Create Plugin: Add `buildMode` property to plugin.json asset [#1281](https://github.com/grafana/plugin-tools/pull/1281) ([@sunker](https://github.com/sunker))
6
+
7
+ #### Authors: 1
8
+
9
+ - Erik Sundell ([@sunker](https://github.com/sunker))
10
+
11
+ ---
12
+
1
13
  # v5.7.5 (Fri Nov 01 2024)
2
14
 
3
15
  #### 🐛 Bug Fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "5.7.5",
3
+ "version": "5.8.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -86,5 +86,5 @@
86
86
  "engines": {
87
87
  "node": ">=20"
88
88
  },
89
- "gitHead": "8464893065b24f1b9e076d937ebf21f5c20047b2"
89
+ "gitHead": "73b041709fcc4b533773e30b5eff2cbc4aa56374"
90
90
  }
@@ -0,0 +1,34 @@
1
+ import * as webpack from 'webpack';
2
+
3
+ const PLUGIN_NAME = 'BuildModeWebpack';
4
+
5
+ export class BuildModeWebpackPlugin {
6
+ apply(compiler: webpack.Compiler) {
7
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
8
+ compilation.hooks.processAssets.tap(
9
+ {
10
+ name: PLUGIN_NAME,
11
+ stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
12
+ },
13
+ async () => {
14
+ const assets = compilation.getAssets();
15
+ for (const asset of assets) {
16
+ if (asset.name.endsWith('plugin.json')) {
17
+ console.log(asset.name);
18
+ const pluginJsonString = asset.source.source().toString();
19
+ const pluginJsonWithBuildMode = JSON.stringify(
20
+ {
21
+ ...JSON.parse(pluginJsonString),
22
+ buildMode: compilation.options.mode,
23
+ },
24
+ null,
25
+ 4
26
+ );
27
+ compilation.updateAsset(asset.name, new webpack.sources.RawSource(pluginJsonWithBuildMode));
28
+ }
29
+ }
30
+ }
31
+ );
32
+ });
33
+ }
34
+ }
@@ -16,6 +16,7 @@ import { type Configuration, BannerPlugin } from 'webpack';
16
16
  import LiveReloadPlugin from 'webpack-livereload-plugin';
17
17
  import VirtualModulesPlugin from 'webpack-virtual-modules';
18
18
 
19
+ import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin';
19
20
  import { DIST_DIR, SOURCE_DIR } from './constants';
20
21
  import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';
21
22
 
@@ -187,6 +188,7 @@ const config = async (env): Promise<Configuration> => {
187
188
  },
188
189
 
189
190
  plugins: [
191
+ new BuildModeWebpackPlugin(),
190
192
  virtualPublicPath,
191
193
  // Insert create plugin version information into the bundle
192
194
  new BannerPlugin({