diff --git a/.changeset/gentle-ravens-look.md b/.changeset/gentle-ravens-look.md new file mode 100644 index 000000000..e1a0b42e7 --- /dev/null +++ b/.changeset/gentle-ravens-look.md @@ -0,0 +1,5 @@ +--- +'@kitql/helper': patch +--- + +Remove colors from browser in production diff --git a/packages/helper/src/lib/colors/index.ts b/packages/helper/src/lib/colors/index.ts index 93024ecc9..2376ca320 100644 --- a/packages/helper/src/lib/colors/index.ts +++ b/packages/helper/src/lib/colors/index.ts @@ -1,4 +1,4 @@ -import { BROWSER } from 'esm-env' +import { BROWSER, DEV } from 'esm-env' import * as stylesBrowser from './stylesBrowser.js' import * as stylesNode from './stylesNode.js' import type { Style } from './types.js' @@ -25,6 +25,9 @@ const START1 = `$$KitQL_` const START2 = `_KitQL$$` const END = `$$KitQLEND$$` const colorBrowser = (style: Style, str: string) => { + if (BROWSER && !DEV) { + return str + } return `${START1}${style}${START2}${str}${END}` } @@ -53,10 +56,13 @@ const getAllIndexOf = (str: string, subStr: string) => { return indexes } -export const colorProcess = (str: string) => { +export const colorProcess = (str: string): string[] => { if (!BROWSER) { return [str] } + if (BROWSER && !DEV) { + return [str] + } const originalStr = str const posToReplace: { index: number; browser: string }[] = []