diff --git a/packages/create-plugin/src/utils/tests/utils.templates.test.ts b/packages/create-plugin/src/utils/tests/utils.templates.test.ts index 818bd3888..a1e22dcd7 100644 --- a/packages/create-plugin/src/utils/tests/utils.templates.test.ts +++ b/packages/create-plugin/src/utils/tests/utils.templates.test.ts @@ -14,7 +14,7 @@ describe('Utils / Templates', () => { expect(templateFiles.length).toBeGreaterThan(0); // A file that should live in this sub-directory - expect(templateFiles.find((t) => t.includes('custom.d.ts'))).not.toBeUndefined(); + expect(templateFiles.find((t) => t.includes('bundler-rules.d.ts'))).not.toBeUndefined(); // Something that should not be found in this sub-directory expect(templateFiles.find((t) => t.includes('Dockerfile'))).toBeUndefined(); @@ -35,7 +35,7 @@ describe('Utils / Templates', () => { }); test('should be possible to filter for a single file', () => { - const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, '.config/types/custom.d.ts'); + const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, '.config/types/bundler-rules.d.ts'); expect(Array.isArray(templateFiles)).toBe(true); expect(templateFiles.length).toBe(1); diff --git a/packages/create-plugin/templates/common/.config/README.md b/packages/create-plugin/templates/common/.config/README.md index 1478e3bbd..5ba318665 100644 --- a/packages/create-plugin/templates/common/.config/README.md +++ b/packages/create-plugin/templates/common/.config/README.md @@ -106,9 +106,9 @@ We are going to use [`webpack-merge`](https://github.com/survivejs/webpack-merge // webpack.config.ts import type { Configuration } from 'webpack'; import { merge } from 'webpack-merge'; -import grafanaConfig from './.config/webpack/webpack.config'; +import grafanaConfig, { type Env } from './.config/webpack/webpack.config'; -const config = async (env): Promise => { +const config = async (env: Env): Promise => { const baseConfig = await grafanaConfig(env); return merge(baseConfig, { diff --git a/packages/create-plugin/templates/common/.config/types/custom.d.ts b/packages/create-plugin/templates/common/.config/types/bundler-rules.d.ts similarity index 91% rename from packages/create-plugin/templates/common/.config/types/custom.d.ts rename to packages/create-plugin/templates/common/.config/types/bundler-rules.d.ts index 64e6eaa6f..e67197c5d 100644 --- a/packages/create-plugin/templates/common/.config/types/custom.d.ts +++ b/packages/create-plugin/templates/common/.config/types/bundler-rules.d.ts @@ -25,8 +25,8 @@ declare module '*.webp' { } declare module '*.svg' { - const content: string; - export default content; + const src: string; + export default src; } // Font declarations diff --git a/packages/create-plugin/templates/common/.config/types/webpack-plugins.d.ts b/packages/create-plugin/templates/common/.config/types/webpack-plugins.d.ts new file mode 100644 index 000000000..6dbab109c --- /dev/null +++ b/packages/create-plugin/templates/common/.config/types/webpack-plugins.d.ts @@ -0,0 +1,83 @@ +declare module 'replace-in-file-webpack-plugin' { + import { Compiler, Plugin } from 'webpack'; + + interface ReplaceRule { + search: string | RegExp; + replace: string | ((match: string) => string); + } + + interface ReplaceOption { + dir?: string; + files?: string[]; + test?: RegExp | RegExp[]; + rules: ReplaceRule[]; + } + + class ReplaceInFilePlugin extends Plugin { + constructor(options?: ReplaceOption[]); + options: ReplaceOption[]; + apply(compiler: Compiler): void; + } + + export = ReplaceInFilePlugin; +} + +declare module 'webpack-livereload-plugin' { + import { ServerOptions } from 'https'; + import { Compiler, Plugin, Stats, Compilation } from 'webpack'; + + interface Options extends Pick { + /** + * protocol for livereload `