searxng/client/simple/vite.config.ts
dependabot[bot] 687121d584
[upd] web-client (simple): Bump the minor group in /client/simple with 2 updates (#5202)
* [upd] web-client (simple): Bump the minor group

Bumps the minor group in /client/simple with 2 updates: [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) and [stylelint](https://github.com/stylelint/stylelint).


Updates `@biomejs/biome` from 2.2.2 to 2.2.4
- [Release notes](https://github.com/biomejs/biome/releases)
- [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md)
- [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.2.4/packages/@biomejs/biome)

Updates `stylelint` from 16.23.1 to 16.24.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/16.23.1...16.24.0)

---
updated-dependencies:
- dependency-name: "@biomejs/biome"
  dependency-version: 2.2.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor
- dependency-name: stylelint
  dependency-version: 16.24.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* update biome schema

* update rolldown

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Gabaldon <igabaldon@inetol.net>
2025-09-12 10:59:25 +02:00

191 lines
4.8 KiB
TypeScript

// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* CONFIG: https://vite.dev/config/
*/
import { resolve } from "node:path";
import { constants as zlibConstants } from "node:zlib";
import browserslistToEsbuild from "browserslist-to-esbuild";
import { browserslistToTargets } from "lightningcss";
import type { PreRenderedAsset } from "rolldown";
import type { Config } from "svgo";
import type { UserConfig } from "vite";
import analyzer from "vite-bundle-analyzer";
import manifest from "./package.json" with { type: "json" };
import { plg_svg2png, plg_svg2svg } from "./tools/plg.ts";
const ROOT = "../../"; // root of the git repository
const PATH = {
brand: "src/brand/",
dist: resolve(ROOT, "searx/static/themes/simple/"),
modules: "node_modules/",
src: "src/",
templates: resolve(ROOT, "searx/templates/simple/")
} as const;
const svg2svg_opts: Config = {
plugins: [{ name: "preset-default" }, "sortAttrs", "convertStyleToAttrs"]
};
const svg2svg_favicon_opts: Config = {
plugins: [{ name: "preset-default" }, "sortAttrs"]
};
export default {
base: "/static/themes/simple/",
publicDir: "static/",
build: {
target: browserslistToEsbuild(manifest.browserslist),
assetsDir: "",
outDir: PATH.dist,
manifest: "manifest.json",
emptyOutDir: true,
sourcemap: true,
rolldownOptions: {
input: {
// build CSS files
"searxng-ltr.css": `${PATH.src}/less/style-ltr.less`,
"searxng-rtl.css": `${PATH.src}/less/style-rtl.less`,
"rss.css": `${PATH.src}/less/rss.less`,
// build script files
"searxng.core": `${PATH.src}/js/core/index.ts`,
// ol pkg
ol: `${PATH.src}/js/pkg/ol.ts`,
"ol.css": `${PATH.modules}/ol/ol.css`
},
// file naming conventions / pathnames are relative to outDir (PATH.dist)
output: {
entryFileNames: "js/[name].min.js",
chunkFileNames: "js/[name].min.js",
assetFileNames: ({ names }: PreRenderedAsset): string => {
const [name] = names;
const extension = name?.split(".").pop();
switch (extension) {
case "css":
return "css/[name].min[extname]";
case "js":
return "js/[name].min[extname]";
case "png":
case "svg":
return "img/[name][extname]";
default:
console.warn("Unknown asset:", name);
return "[name][extname]";
}
}
}
}
}, // end: build
plugins: [
// -- bundle analyzer
analyzer({
enabled: process.env.VITE_BUNDLE_ANALYZE === "true",
analyzerPort: "auto",
summary: true,
reportTitle: manifest.name,
// sidecars with max compression
gzipOptions: {
level: zlibConstants.Z_BEST_COMPRESSION
},
brotliOptions: {
params: {
[zlibConstants.BROTLI_PARAM_QUALITY]: zlibConstants.BROTLI_MAX_QUALITY
}
}
}),
// -- svg images
plg_svg2svg(
[
{
src: `${PATH.src}/svg/empty_favicon.svg`,
dest: `${PATH.dist}/img/empty_favicon.svg`
},
{
src: `${PATH.src}/svg/select-dark.svg`,
dest: `${PATH.dist}/img/select-dark.svg`
},
{
src: `${PATH.src}/svg/select-light.svg`,
dest: `${PATH.dist}/img/select-light.svg`
}
],
svg2svg_opts
),
// SearXNG brand (static)
plg_svg2png([
{
src: `${PATH.brand}/searxng-wordmark.svg`,
dest: `${PATH.dist}/img/favicon.png`
},
{
src: `${PATH.brand}/searxng.svg`,
dest: `${PATH.dist}/img/searxng.png`
}
]),
// -- svg
plg_svg2svg(
[
{
src: `${PATH.brand}/searxng.svg`,
dest: `${PATH.dist}/img/searxng.svg`
},
{
src: `${PATH.brand}/img_load_error.svg`,
dest: `${PATH.dist}/img/img_load_error.svg`
}
],
svg2svg_opts
),
// -- favicon
plg_svg2svg(
[
{
src: `${PATH.brand}/searxng-wordmark.svg`,
dest: `${PATH.dist}/img/favicon.svg`
}
],
svg2svg_favicon_opts
),
// -- simple templates
plg_svg2svg(
[
{
src: `${PATH.brand}/searxng-wordmark.svg`,
dest: `${PATH.templates}/searxng-wordmark.min.svg`
}
],
svg2svg_opts
)
], // end: plugins
// FIXME: missing CCS sourcemaps!!
// see: https://github.com/vitejs/vite/discussions/13845#discussioncomment-11992084
//
// what I have tried so far (see config below):
//
// - build.sourcemap
// - esbuild.sourcemap
// - css.preprocessorOptions.less.sourceMap
css: {
transformer: "lightningcss",
lightningcss: {
targets: browserslistToTargets(manifest.browserslist)
},
devSourcemap: true
} // end: css
} satisfies UserConfig;