forked from VictoriaMetrics/victoriametrics-datasource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
executable file
·57 lines (52 loc) · 1.61 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import { merge } from 'webpack-merge';
import grafanaConfig from './.config/webpack/webpack.config';
const path = require('path');
// @ts-ignore
const config = (env) => {
const defaultConfig = grafanaConfig(env);
if (Array.isArray(defaultConfig.externals)) {
defaultConfig.externals = defaultConfig.externals.filter((item) => item !== '@emotion/react');
}
return merge(defaultConfig, {
output: {
clean: false,
path: path.resolve(__dirname, 'victoriametrics-datasource'),
filename: '[name].js',
// Keep publicPath relative for host.com/grafana/ deployments
publicPath: '/public/plugins/victoriametrics-datasource/',
},
resolve: {
alias: {
app: path.resolve(__dirname, 'app/'),
packages: path.resolve(__dirname, 'packages/'),
img: path.resolve(__dirname, 'img/'),
},
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
type: 'asset/resource',
generator: { filename: 'static/img/[name].[hash:8][ext]' },
},
],
},
performance: { hints: false },
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
path.join(__dirname, 'victoriametrics-datasource', '**/*.{js,css}'),
],
cleanAfterEveryBuildPatterns: [
'!**/*.bin', // don't clear backend build
],
}),
]
});
}
export default config;