mirror of
https://github.com/SigNoz/signoz.git
synced 2026-02-23 16:59:30 +00:00
Compare commits
1 Commits
SIG_3889
...
chore/buil
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a89584bea9 |
@@ -1,8 +1,52 @@
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"path": "./build/**.js",
|
||||
"maxSize": "1.2MB"
|
||||
"path": "./build/runtime~*.js",
|
||||
"maxSize": "50KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-react.*.js",
|
||||
"maxSize": "300KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-antd.*.js",
|
||||
"maxSize": "1MB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-antd-icons.*.js",
|
||||
"maxSize": "2.5MB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-charts.*.js",
|
||||
"maxSize": "400KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-react-query.*.js",
|
||||
"maxSize": "100KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-utilities.*.js",
|
||||
"maxSize": "600KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-monaco.*.js",
|
||||
"maxSize": "3MB"
|
||||
},
|
||||
{
|
||||
"path": "./build/vendors-common.*.js",
|
||||
"maxSize": "800KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/main.*.js",
|
||||
"maxSize": "500KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/Home.*.js",
|
||||
"maxSize": "300KB"
|
||||
},
|
||||
{
|
||||
"path": "./build/*.js",
|
||||
"maxSize": "1MB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
|
||||
import { getColorsForSeverityLabels, isRedLike } from '../utils';
|
||||
|
||||
describe('getColorsForSeverityLabels', () => {
|
||||
it('should return slate for blank labels', () => {
|
||||
expect(getColorsForSeverityLabels('', 0)).toBe(Color.BG_SLATE_300);
|
||||
expect(getColorsForSeverityLabels(' ', 0)).toBe(Color.BG_SLATE_300);
|
||||
});
|
||||
|
||||
it('should return correct colors for known severity variants', () => {
|
||||
expect(getColorsForSeverityLabels('INFO', 0)).toBe(Color.BG_ROBIN_600);
|
||||
expect(getColorsForSeverityLabels('ERROR', 0)).toBe(Color.BG_CHERRY_600);
|
||||
expect(getColorsForSeverityLabels('WARN', 0)).toBe(Color.BG_AMBER_600);
|
||||
expect(getColorsForSeverityLabels('DEBUG', 0)).toBe(Color.BG_AQUA_600);
|
||||
expect(getColorsForSeverityLabels('TRACE', 0)).toBe(Color.BG_FOREST_600);
|
||||
expect(getColorsForSeverityLabels('FATAL', 0)).toBe(Color.BG_SAKURA_600);
|
||||
});
|
||||
|
||||
it('should return non-red colors for unrecognized labels at any index', () => {
|
||||
for (let i = 0; i < 30; i++) {
|
||||
const color = getColorsForSeverityLabels('4', i);
|
||||
expect(isRedLike(color)).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return non-red colors for numeric severity text', () => {
|
||||
const numericLabels = ['1', '2', '4', '9', '13', '17', '21'];
|
||||
numericLabels.forEach((label) => {
|
||||
const color = getColorsForSeverityLabels(label, 0);
|
||||
expect(isRedLike(color)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,16 +1,7 @@
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import { themeColors } from 'constants/theme';
|
||||
import { colors } from 'lib/getRandomColor';
|
||||
|
||||
// Function to determine if a color is "red-like" based on its RGB values
|
||||
export function isRedLike(hex: string): boolean {
|
||||
const r = parseInt(hex.slice(1, 3), 16);
|
||||
const g = parseInt(hex.slice(3, 5), 16);
|
||||
const b = parseInt(hex.slice(5, 7), 16);
|
||||
return r > 180 && r > g * 1.4 && r > b * 1.4;
|
||||
}
|
||||
|
||||
const SAFE_FALLBACK_COLORS = colors.filter((c) => !isRedLike(c));
|
||||
|
||||
const SEVERITY_VARIANT_COLORS: Record<string, string> = {
|
||||
TRACE: Color.BG_FOREST_600,
|
||||
Trace: Color.BG_FOREST_500,
|
||||
@@ -76,13 +67,8 @@ export function getColorsForSeverityLabels(
|
||||
label: string,
|
||||
index: number,
|
||||
): string {
|
||||
const trimmed = label.trim();
|
||||
|
||||
if (!trimmed) {
|
||||
return Color.BG_SLATE_300;
|
||||
}
|
||||
|
||||
const variantColor = SEVERITY_VARIANT_COLORS[trimmed];
|
||||
// Check if we have a direct mapping for this severity variant
|
||||
const variantColor = SEVERITY_VARIANT_COLORS[label.trim()];
|
||||
if (variantColor) {
|
||||
return variantColor;
|
||||
}
|
||||
@@ -117,8 +103,5 @@ export function getColorsForSeverityLabels(
|
||||
return Color.BG_SAKURA_500;
|
||||
}
|
||||
|
||||
return (
|
||||
SAFE_FALLBACK_COLORS[index % SAFE_FALLBACK_COLORS.length] ||
|
||||
Color.BG_SLATE_400
|
||||
);
|
||||
return colors[index % colors.length] || themeColors.red;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const store = createStore(
|
||||
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
|
||||
if (window !== undefined) {
|
||||
if (window !== undefined && process.env.NODE_ENV === 'development') {
|
||||
window.store = store;
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ const config = {
|
||||
plugins,
|
||||
optimization: {
|
||||
chunkIds: 'named',
|
||||
concatenateModules: false,
|
||||
concatenateModules: true, // Enable module concatenation for better tree-shaking and smaller bundles
|
||||
emitOnErrors: true,
|
||||
flagIncludedChunks: true,
|
||||
innerGraph: true, // tells webpack whether to conduct inner graph analysis for unused exports.
|
||||
@@ -182,6 +182,85 @@ const config = {
|
||||
runtimeChunk: {
|
||||
name: (entrypoint) => `runtime~${entrypoint.name}`,
|
||||
},
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
maxInitialRequests: 30,
|
||||
minSize: 20000,
|
||||
cacheGroups: {
|
||||
// Vendor libraries - React, React-DOM, Redux, Router
|
||||
vendor: {
|
||||
test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|react-redux|redux|@reduxjs)[\\/]/,
|
||||
name: 'vendors-react',
|
||||
priority: 30,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Ant Design icons (separate from core - icons are huge)
|
||||
antdIcons: {
|
||||
test: /[\\/]node_modules[\\/](@ant-design\/icons)[\\/]/,
|
||||
name: 'vendors-antd-icons',
|
||||
priority: 25,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Ant Design core (without icons) - matches antd and @ant-design but not @ant-design/icons
|
||||
antd: {
|
||||
test: /[\\/]node_modules[\\/](antd|@ant-design(?!\/icons))[\\/]/,
|
||||
name: 'vendors-antd',
|
||||
priority: 20,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// SigNoz UI components
|
||||
signozhq: {
|
||||
test: /[\\/]node_modules[\\/](@signozhq)[\\/]/,
|
||||
name: 'vendors-signozhq',
|
||||
priority: 19,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Chart libraries
|
||||
charts: {
|
||||
test: /[\\/]node_modules[\\/](uplot|chart\.js|@visx|@tanstack\/react-table|@tanstack\/react-virtual)[\\/]/,
|
||||
name: 'vendors-charts',
|
||||
priority: 18,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// React Query
|
||||
reactQuery: {
|
||||
test: /[\\/]node_modules[\\/](react-query|@tanstack\/react-query)[\\/]/,
|
||||
name: 'vendors-react-query',
|
||||
priority: 17,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Large utility libraries
|
||||
utilities: {
|
||||
test: /[\\/]node_modules[\\/](lodash-es|@dnd-kit|dayjs|axios|i18next)[\\/]/,
|
||||
name: 'vendors-utilities',
|
||||
priority: 15,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Monaco editor (very large)
|
||||
monaco: {
|
||||
test: /[\\/]node_modules[\\/](@monaco-editor|monaco-editor)[\\/]/,
|
||||
name: 'vendors-monaco',
|
||||
priority: 16,
|
||||
reuseExistingChunk: true,
|
||||
enforce: true,
|
||||
},
|
||||
// Other vendor libraries
|
||||
common: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: 'vendors-common',
|
||||
priority: 10,
|
||||
minChunks: 2,
|
||||
reuseExistingChunk: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
|
||||
Reference in New Issue
Block a user