mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 13:33:45 +00:00
* fix: ship the Inter, Roboto Mono and Inconsolata faces with the package
Move the woff2 files from client/public/fonts into packages/client/src/theme/fonts
and every @font-face rule (the app's Inter and Roboto Mono faces and
client/src/fonts.css) into theme/fonts.css, which tokens.css imports and the build
copies into dist with the files. Each url() names the file by a new
@librechat/client/fonts/* export: a relative path breaks under Vite with
@tailwindcss/postcss, because Vite inlines the import before Tailwind runs and
Tailwind reports every emitted declaration as coming from the root stylesheet.
The app loads the same files through the same import and still emits them to
assets/fonts with their licences, now read from the package; the $fonts alias is
gone. Inter and Roboto Mono gain their OFL texts beside Inconsolata's. The README's
consumer stylesheet moves the package stylesheet import above @config, where
Vite's inliner no longer skips it. The static checks' bundle freshness test reads a
subpath pattern export as the directory it maps into.
* docs: describe how the theme fonts resolve through the package export
* fix: leave subpath pattern exports out of the bundle freshness check
A pattern such as ./dist/fonts/* names no entry the design rules load, and
reading it as its directory made the freshness check depend on a directory the
synthetic build in suppression-baseline.spec.ts never dates. The scenario's
mirror of the manifest reading skips patterns the same way.
(cherry picked from commit 681515c9e5)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16485
49 lines
2.4 KiB
JavaScript
49 lines
2.4 KiB
JavaScript
import path from 'node:path';
|
|
import { defineConfig } from 'tsdown';
|
|
|
|
// Mirror the prior Rollup `@rollup/plugin-replace` substitutions: only these three are
|
|
// baked at lib-build time. `import.meta.env.MODE` and `REACT_APP_*` are intentionally left
|
|
// intact so the consuming Vite app resolves them at app-build time.
|
|
const define = {
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
|
|
'process.env.VITE_ENABLE_LOGGER': JSON.stringify(process.env.VITE_ENABLE_LOGGER || 'false'),
|
|
'process.env.VITE_LOGGER_FILTER': JSON.stringify(process.env.VITE_LOGGER_FILTER || ''),
|
|
};
|
|
|
|
export default defineConfig({
|
|
entry: ['src/index.ts'],
|
|
format: ['esm', 'cjs'],
|
|
platform: 'browser',
|
|
dts: { oxc: true },
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
// Warn on module cycles at build time; CI enforces via config/circular-deps.mjs.
|
|
checks: { circularDependency: true },
|
|
// Force .mjs/.cjs (and .d.mts/.d.cts) regardless of package `type`, so the package can stay
|
|
// CommonJS (jest.config.js / babel.config.js are CJS) while still shipping dual ESM/CJS.
|
|
fixedExtension: true,
|
|
define,
|
|
copy: [
|
|
{ from: 'src/icons/provider/assets', to: 'dist' },
|
|
// The color tokens ship as CSS: an app imports `@librechat/client/theme.css` into the
|
|
// stylesheet that imports Tailwind, and gets `bg-surface-primary` and the rest. `to` names
|
|
// the destination directory, not the file, pointing it at `dist/theme.css` produced a
|
|
// directory of that name holding `tokens.css`, and the export resolved to a folder, so the
|
|
// file keeps its name in `dist` and the export maps `./theme.css` onto it. It imports the stock
|
|
// values and the font faces beside it by relative path, and the faces load `fonts/`, so all of
|
|
// them ship side by side.
|
|
{ from: 'src/theme/tokens.css', to: 'dist' },
|
|
{ from: 'src/theme/defaults.css', to: 'dist' },
|
|
{ from: 'src/theme/fonts.css', to: 'dist' },
|
|
{ from: 'src/theme/fonts', to: 'dist' },
|
|
],
|
|
// Extract all component CSS into a single `dist/style.css` (no import left in the JS, so the
|
|
// CJS output stays valid CommonJS). Consumers import `@librechat/client/style.css` once.
|
|
css: { inject: false },
|
|
// Externalize every third-party import (consumers provide the peers + react/jsx-runtime);
|
|
// bundle only relative, `~`-aliased, and absolute sources.
|
|
deps: {
|
|
neverBundle: (id) => !id.startsWith('.') && !id.startsWith('~') && !path.isAbsolute(id),
|
|
onlyBundle: false,
|
|
},
|
|
});
|