-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
41 lines (38 loc) · 1.18 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import path from 'path';
import { type Configuration } from 'webpack';
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
import grafanaConfig from './.config/webpack/webpack.config';
import { getPackageJson } from './.config/webpack/utils';
import { DIST_DIR, SOURCE_DIR } from './.config/webpack/constants';
const config = async (env): Promise<Configuration> => {
const baseConfig = await grafanaConfig(env);
const appPluginJson = () => require(path.resolve(process.cwd(), `${SOURCE_DIR}/app/plugin.json`));
return {
...baseConfig,
plugins: [
// @ts-expect-error
...baseConfig.plugins,
new ReplaceInFileWebpackPlugin([
{
dir: `${DIST_DIR}/app`,
files: ['plugin.json'],
rules: [
{
search: /\%VERSION\%/g,
replace: getPackageJson().version,
},
{
search: /\%TODAY\%/g,
replace: new Date().toISOString().substring(0, 10),
},
{
search: /\%PLUGIN_ID\%/g,
replace: appPluginJson().id,
},
],
},
]),
],
};
};
export default config;