2024-08-16 18:43:52 +02:00
|
|
|
import { Configuration, EnvironmentPlugin } from 'webpack';
|
2024-02-22 14:37:03 +01:00
|
|
|
import LiveReloadPlugin from 'webpack-livereload-plugin';
|
2024-02-21 17:49:10 +03:00
|
|
|
import { mergeWithRules, CustomizeRule } from 'webpack-merge';
|
2024-02-22 14:37:03 +01:00
|
|
|
|
2024-02-21 17:49:10 +03:00
|
|
|
import grafanaConfig from './.config/webpack/webpack.config';
|
|
|
|
|
|
|
|
|
|
const config = async (env): Promise<Configuration> => {
|
|
|
|
|
const baseConfig = await grafanaConfig(env);
|
|
|
|
|
const customConfig = {
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.[tj]sx?$/,
|
|
|
|
|
use: {
|
|
|
|
|
options: {
|
|
|
|
|
jsc: {
|
|
|
|
|
parser: {
|
|
|
|
|
decorators: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-05-30 12:10:13 +01:00
|
|
|
{
|
|
|
|
|
test: /\.s[ac]ss$/,
|
|
|
|
|
use: [
|
|
|
|
|
'style-loader',
|
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
modules: {
|
|
|
|
|
auto: true,
|
|
|
|
|
localIdentName: env.development ? '[path][name]__[local]' : '[name]__[hash:base64]',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
'sass-loader',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
use: [
|
|
|
|
|
'style-loader',
|
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
modules: {
|
|
|
|
|
auto: true,
|
|
|
|
|
localIdentName: env.development ? '[path][name]__[local]' : '[name]__[hash:base64]',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2024-02-21 17:49:10 +03:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
watchOptions: {
|
|
|
|
|
ignored: ['**/node_modules/', '**/dist'],
|
|
|
|
|
},
|
2024-02-22 14:37:03 +01:00
|
|
|
plugins: [
|
2024-02-26 14:52:26 +01:00
|
|
|
...(baseConfig.plugins?.filter((plugin) => !(plugin instanceof LiveReloadPlugin)) || []),
|
2024-09-17 17:11:30 +02:00
|
|
|
...(env.development
|
|
|
|
|
? [
|
|
|
|
|
new LiveReloadPlugin({
|
|
|
|
|
appendScriptTag: true,
|
|
|
|
|
useSourceHash: true,
|
|
|
|
|
protocol: 'http',
|
|
|
|
|
hostname: 'localhost',
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
: []),
|
2024-02-22 14:37:03 +01:00
|
|
|
new EnvironmentPlugin({
|
2024-06-20 13:54:07 +02:00
|
|
|
NODE_ENV: 'development',
|
2024-07-30 07:50:41 +02:00
|
|
|
PLUGIN_ID: 'grafana-oncall-app',
|
2024-02-22 14:37:03 +01:00
|
|
|
}),
|
|
|
|
|
],
|
2024-02-21 17:49:10 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return mergeWithRules({
|
|
|
|
|
module: {
|
|
|
|
|
rules: {
|
|
|
|
|
test: CustomizeRule.Match,
|
|
|
|
|
use: CustomizeRule.Merge,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
watchOptions: {
|
|
|
|
|
use: CustomizeRule.Merge,
|
|
|
|
|
},
|
2024-02-26 14:52:26 +01:00
|
|
|
plugins: CustomizeRule.Replace,
|
2024-02-21 17:49:10 +03:00
|
|
|
})(baseConfig, customConfig);
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-30 07:50:41 +02:00
|
|
|
export default config;
|