oncall-engine/grafana-plugin/webpack.config.ts
Dominik Broj dd6d2ab161
chore: always point livereload to localhost (#5029)
# What this PR does

Always point livereload to localhost. I missed this change when
submitting this PR: https://github.com/grafana/oncall/pull/5021

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-09-17 15:11:30 +00:00

93 lines
2.3 KiB
TypeScript

import { Configuration, EnvironmentPlugin } from 'webpack';
import LiveReloadPlugin from 'webpack-livereload-plugin';
import { mergeWithRules, CustomizeRule } from 'webpack-merge';
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,
},
},
},
},
},
{
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]',
},
},
},
],
},
],
},
watchOptions: {
ignored: ['**/node_modules/', '**/dist'],
},
plugins: [
...(baseConfig.plugins?.filter((plugin) => !(plugin instanceof LiveReloadPlugin)) || []),
...(env.development
? [
new LiveReloadPlugin({
appendScriptTag: true,
useSourceHash: true,
protocol: 'http',
hostname: 'localhost',
}),
]
: []),
new EnvironmentPlugin({
NODE_ENV: 'development',
PLUGIN_ID: 'grafana-oncall-app',
}),
],
};
return mergeWithRules({
module: {
rules: {
test: CustomizeRule.Match,
use: CustomizeRule.Merge,
},
},
watchOptions: {
use: CustomizeRule.Merge,
},
plugins: CustomizeRule.Replace,
})(baseConfig, customConfig);
};
export default config;