diff --git a/web/instrumentation-client.ts b/web/instrumentation-client.ts index 4c9e6a10e79..4b56b638491 100644 --- a/web/instrumentation-client.ts +++ b/web/instrumentation-client.ts @@ -1,5 +1,6 @@ import { IS_DEV } from '@/config' import { env } from '@/env' +import 'uno.css' async function main() { // Polyfill for Array.prototype.toSpliced (ES2023, Chrome 110+) diff --git a/web/postcss.config.js b/web/postcss.config.js deleted file mode 100644 index 92008266455..00000000000 --- a/web/postcss.config.js +++ /dev/null @@ -1,9 +0,0 @@ -import UnoCSS from '@unocss/postcss' -import autoprefixer from 'autoprefixer' - -export default { - plugins: [ - UnoCSS(), - autoprefixer(), - ], -} diff --git a/web/uno.config.ts b/web/uno.config.ts index a4e036dfff6..250c01b3cee 100644 --- a/web/uno.config.ts +++ b/web/uno.config.ts @@ -104,16 +104,19 @@ export default defineConfig({ ['bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]', { 'background-color': 'var(--shiki-dark-bg,var(--sdm-bg,inherit))' }], ], content: { - filesystem: [ - './app/**/*.{js,ts,jsx,tsx,mdx,css}', - './context/**/*.{js,ts,jsx,tsx,css}', - './node_modules/streamdown/dist/*.js', - './node_modules/@streamdown/math/dist/*.js', - '!./app/**/__tests__/**', - '!./context/**/__tests__/**', - '!./app/**/*.{spec,test}.{js,ts,jsx,tsx}', - '!./context/**/*.{spec,test}.{js,ts,jsx,tsx}', - ], + pipeline: { + include: [ + /\.(vue|svelte|[jt]sx|vine.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/, + /\/app\/.*\.[jt]s($|\?)/, + /\/context\/.*\.[jt]s($|\?)/, + /\/node_modules\/streamdown\/dist\/.*\.js($|\?)/, + /\/node_modules\/@streamdown\/math\/dist\/.*\.js($|\?)/, + ], + exclude: [ + /\/__tests__\//, + /\.(spec|test)\.[jt]sx?($|\?)/, + ], + }, }, presets: [ presetWind3(), diff --git a/web/vite.config.ts b/web/vite.config.ts index c65ea1215bd..a8bace4ea1e 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,6 +1,5 @@ import { fileURLToPath } from 'node:url' import react from '@vitejs/plugin-react' -import autoprefixer from 'autoprefixer' import UnoCSS from 'unocss/vite' import vinext from 'vinext' import Inspect from 'vite-plugin-inspect' @@ -13,36 +12,6 @@ import { nextStaticImageTestPlugin } from './plugins/vite/next-static-image-test const projectRoot = fileURLToPath(new URL('.', import.meta.url)) const isCI = !!process.env.CI const rootClientInjectTarget = getRootClientInjectTarget(projectRoot) -const unoCssEntryTarget = `${projectRoot}app/layout.tsx` -const unoGlobalsCssTarget = `${projectRoot}app/styles/globals.css` - -const injectUnoCssPlugin = { - name: 'inject-uno-css-entry', - enforce: 'pre' as const, - transform(code: string, id: string) { - if (id !== unoCssEntryTarget || code.includes('virtual:uno.css')) - return - - return { - code: `import 'virtual:uno.css'\n${code}`, - map: null, - } - }, -} - -const stripUnoPreflightDirectivePlugin = { - name: 'strip-uno-preflight-directive', - enforce: 'pre' as const, - transform(code: string, id: string) { - if (id !== unoGlobalsCssTarget || !code.includes('@unocss !preflights;')) - return - - return { - code: code.replace('@unocss !preflights;', ''), - map: null, - } - }, -} export default defineConfig(({ mode }) => { const isTest = mode === 'test' @@ -81,8 +50,6 @@ export default defineConfig(({ mode }) => { injectTarget: rootClientInjectTarget, projectRoot, }), - injectUnoCssPlugin, - stripUnoPreflightDirectivePlugin, UnoCSS(), react(), vinext({ react: false }), @@ -95,13 +62,6 @@ export default defineConfig(({ mode }) => { resolve: { tsconfigPaths: true, }, - css: { - postcss: { - plugins: [ - autoprefixer(), - ], - }, - }, // vinext related config ...(!isTest && !isStorybook