|
7 | 7 |
|
8 | 8 | import rspack, { type Configuration } from '@rspack/core';
|
9 | 9 | import ESLintPlugin from 'eslint-webpack-plugin';
|
10 |
| -import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; |
| 10 | +import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin'; |
11 | 11 | import path from 'path';
|
12 | 12 | import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
|
13 | 13 | import TerserPlugin from 'terser-webpack-plugin';
|
14 | 14 | import { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';
|
15 | 15 | import RspackLiveReloadPlugin from './liveReloadPlugin';
|
16 |
| - |
| 16 | +import { BuildModeRspackPlugin } from './BuildModeRspackPlugin'; |
17 | 17 | import { DIST_DIR, SOURCE_DIR } from './constants';
|
18 | 18 | import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';
|
19 | 19 |
|
| 20 | +const { SubresourceIntegrityPlugin } = rspack.experiments; |
20 | 21 | const pluginJson = getPluginJson();
|
21 | 22 | const cpVersion = getCPConfigVersion();
|
22 | 23 |
|
@@ -57,12 +58,15 @@ const config = async (env): Promise<Configuration> => {
|
57 | 58 | 'react-redux',
|
58 | 59 | 'redux',
|
59 | 60 | 'rxjs',
|
60 |
| - 'react-router', |
| 61 | + 'react-router',{{#unless useReactRouterV6}} |
| 62 | + 'react-router-dom',{{/unless}} |
61 | 63 | 'd3',
|
62 |
| - 'angular', |
63 |
| - '@grafana/ui', |
| 64 | + 'angular',{{#unless bundleGrafanaUI}} |
| 65 | + '@grafana/ui',{{/unless}} |
64 | 66 | '@grafana/runtime',
|
65 |
| - '@grafana/data', |
| 67 | + '@grafana/data',{{#if bundleGrafanaUI}} |
| 68 | + 'react-inlinesvg', |
| 69 | + 'i18next',{{/if}} |
66 | 70 |
|
67 | 71 | // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix
|
68 | 72 | //@ts-ignore - rspack types seem to be a bit broken here.
|
@@ -167,16 +171,22 @@ const config = async (env): Promise<Configuration> => {
|
167 | 171 | },
|
168 | 172 |
|
169 | 173 | output: {
|
| 174 | + clean: { |
| 175 | + keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), |
| 176 | + }, |
170 | 177 | filename: '[name].js',
|
| 178 | + chunkFilename: env.production ? '[name].js?_cache=[contenthash]' : '[name].js', |
171 | 179 | library: {
|
172 | 180 | type: 'amd',
|
173 | 181 | },
|
174 | 182 | path: path.resolve(process.cwd(), DIST_DIR),
|
175 |
| - publicPath: `./`, |
| 183 | + publicPath: `public/plugins/${pluginJson.id}/`, |
176 | 184 | uniqueName: pluginJson.id,
|
| 185 | + crossOriginLoading: 'anonymous', |
177 | 186 | },
|
178 | 187 |
|
179 | 188 | plugins: [
|
| 189 | + new BuildModeRspackPlugin(), |
180 | 190 | virtualPublicPath,
|
181 | 191 | // Insert create plugin version information into the bundle
|
182 | 192 | new rspack.BannerPlugin({
|
@@ -223,10 +233,13 @@ const config = async (env): Promise<Configuration> => {
|
223 | 233 | ],
|
224 | 234 | },
|
225 | 235 | ]),
|
| 236 | + new SubresourceIntegrityPlugin({ |
| 237 | + hashFuncNames: ["sha256"], |
| 238 | + }), |
226 | 239 | ...(env.development
|
227 | 240 | ? [
|
228 | 241 | new RspackLiveReloadPlugin(),
|
229 |
| - new ForkTsCheckerWebpackPlugin({ |
| 242 | + new TsCheckerRspackPlugin({ |
230 | 243 | async: Boolean(env.development),
|
231 | 244 | issue: {
|
232 | 245 | include: [{ file: '**/*.{ts,tsx}' }],
|
@@ -255,8 +268,6 @@ const config = async (env): Promise<Configuration> => {
|
255 | 268 | };
|
256 | 269 | }
|
257 | 270 |
|
258 |
| - |
259 |
| - |
260 | 271 | return baseConfig;
|
261 | 272 | };
|
262 | 273 |
|
|
0 commit comments