这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@return42
Copy link
Member

@return42 return42 commented Feb 5, 2025

What does this PR do?

Migrate web client development (simple theme) from grunt to Vite.

Vite consists of a builder and a server, this PR only implements the build, what grunt has done so far. We will integrate the vite server into our development processes in a followup PR.

Why is this change important?

  1. grunt and its plugins are no longer maintained
  2. we need a modern developer environment for front-end (FE) development

How to test this PR locally?

Start a server (make run) and see if there are no changes in the frontend. Apart from a few small bugs that have been fixed around the icons, this PR should not bring any changes from the user's point of view.

To test FE development jump to folder client/simple and have a look at the README there.

Notes

The switch to vite in this PR will enable us to develop our FE faster and more securely in future (e.g. we do no longer rely on unmaintained components and can benefit from state of the art technologies).

This PR deliberately avoids changes to the JS code and adopts it 1:1 for the time being. In further PRs we should then restructure the JS code base to JS modules (and imports/exports).

The migration to vite currently still has one catch: I have not been able to generate the source maps for the CSS that are generated from the LESS ... perhaps we can find a solution for this in the course of the review ..

Related issues


Closes: #141

@return42 return42 force-pushed the web-client-env branch 4 times, most recently from fcf76e4 to 1aa8135 Compare February 6, 2025 07:21
@return42 return42 requested review from Bnyro and mrpaulblack February 6, 2025 07:36
@return42
Copy link
Member Author

return42 commented Feb 7, 2025

@vojkovic I remember you have custom LESS for the theme .. this PR will move the sources from searx/static/themes/simple/src to client/simple/src .. after merging this PR, you may have to adjust the workflow with which you apply your themes .. I have also already informed @mrpaulblack ... I don't know who else has customizations to the LESS files ...

@vojkovic
Copy link
Member

vojkovic commented Feb 7, 2025

@return42 I appreciate you letting me know - I'll follow this PR and make the changes once the merge happens. :-)

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the JavaScript on the results page is currently not being loaded properly - I can't tell why exactly yet.

To reproduce: Try to Shift-select additional categories with the left mouse button - works on the latest master but not with this PR.

@vojkovic
Copy link
Member

Running this now in production on my instance. privau/searxng@e64d2b9

Haven't noticed any issues just yet. But did notice a considerable speedup in the frontend build time. :)

As mentioned, the main issue currently looks to be that the css sourcemaps not being built.

@vojkovic
Copy link
Member

@return42 Noticed something! - the new svg optimiser seems to be breaking a few svgs like the information-circle and news category icon. There are internal shapes not being coloured.

1 2

return42 added a commit to return42/searxng that referenced this pull request Feb 25, 2025
…n names

This patch implements the template generation of the template:

  searx/templates/simple/icons.html

by the way the icon set (the icon names) has been normalized:

  film-outline   --> film
  magnet-outline --> magnet
  ..
  warning        --> alert

Some missing (categorie) icons had been added.

Some of the ionicons are not suitable for a dark theme, we fixed the svg
manually in src/svg/ionicons:

- searxng#4284 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42
Copy link
Member Author

return42 commented Feb 25, 2025

@return42 Noticed something! - the new svg optimizer seems to be breaking a few svgs

It's not the optimizer ... it's the icons themselves:

There are internal shapes not being colored.

News icon haven't changed (was also broken before) .. but in the old client we had a manually fixed info icon.

I now fixed both icons --> see diff

 // some of the ionicons are not suitable for a dark theme, we fixed the svg
 // manually in src/svg/ionicons

Vite is a build tool, it consists of two major parts [1]:

- A dev server that provides rich feature enhancements over native ES modules,
  for example extremely fast Hot Module Replacement (HMR).

- A build command that bundles your code with Rollup, pre-configured to output
  highly optimized static assets for production.

[1] https://vite.dev/guide/

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
…n names

This patch implements the template generation of the template:

  searx/templates/simple/icons.html

by the way the icon set (the icon names) has been normalized:

  film-outline   --> film
  magnet-outline --> magnet
  ..
  warning        --> alert

Some missing (categorie) icons had been added.

Some of the ionicons are not suitable for a dark theme, we fixed the svg
manually in src/svg/ionicons:

- searxng#4284 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
…to static by plg_svg2svg

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
…vers

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
- upgrade to ubuntu-24.04 to get NodeJS v20
- remove DEBUG (V=1) environment / in a ViteJS env the DEBUG environment is
  reserved for interactive debugging tasks (not for verbose build messages).

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
BTW: Rename the manufacturer-specific name ``ion-icon`` of the icon set in
SerXNG to ``sxng-icon-set`` --> The icon set can be assembled together as
desired in the FE and should therefore not have a manufacturer-specific name in
the style and template definitions.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Related:

- searxng#4322

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Comment on lines +35 to +68
const simple_icons = [
{
base: resolve(HERE, "node_modules/ionicons/dist/svg"),
set: {
"alert": "alert-outline.svg",
"appstore": "apps-outline.svg",
"book": "book-outline.svg",
"close": "close-outline.svg",
"download": "download-outline.svg",
"ellipsis-vertical": "ellipsis-vertical-outline.svg",
"file-tray-full": "file-tray-full-outline.svg",
"film": "film-outline.svg",
"globe": "globe-outline.svg",
"heart": "heart-outline.svg",
"image": "image-outline.svg",
"layers": "layers-outline.svg",
"leecher": "arrow-down.svg",
"location": "location-outline.svg",
"magnet": "magnet-outline.svg",
"musical-notes": "musical-notes-outline.svg",
"navigate-down": "chevron-down-outline.svg",
"navigate-left": "chevron-back-outline.svg",
"navigate-right": "chevron-forward-outline.svg",
"navigate-up": "chevron-up-outline.svg",
"people": "people-outline.svg",
"play": "play-outline.svg",
"radio": "radio-outline.svg",
"save": "save-outline.svg",
"school": "school-outline.svg",
"search": "search-outline.svg",
"seeder": "swap-vertical.svg",
"settings": "settings-outline.svg",
"tv": "tv-outline.svg",
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vojkovic: while we are just talking about icons .. this PR also fix some very old issues with some missing SVGs: e.g. SVGs for seeder, lecher and file size (save) had been missed in the past ..

grafik

grafik

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice - great work with this mate.

@vojkovic
Copy link
Member

Looks good - I had a look at the issue with vite not generating the css source maps. I read over the github discussion and even after checking the source of vite, I can't get them to build either.

Comment on lines -45 to -50
themes.live() {
local LIVE_THEME="${LIVE_THEME:-${1}}"
case "${LIVE_THEME}" in
simple)
theme="searx/static/themes/${LIVE_THEME}"
;;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read over the github discussion and even after checking the source of vite, I can't get them to build either.

@vojkovic many thanks for your research on this .. I guess the issue is related to the minification of the CSS .. but for the build phase I prefer to to minify ..

Vite consists of a builder and a server, this PR only implements the build,

in a follow up PR I will integrate vite's development server in a (new) themes.live command .. then, in the development phase we don't need to minify and have CSS source maps back .. at least I hope so ;-)


BTW: we already have a similar issue with LESS & CSS

The problem may lie in a sub-sub-sub dependency and therefore affects both (vite and less-plugin-clean-css)... but I can only speculate about that ..

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again, looks good to me now! 👍

@return42 return42 merged commit d5ba3bf into searxng:master Feb 28, 2025
9 checks passed
return42 added a commit that referenced this pull request Feb 28, 2025
…n names

This patch implements the template generation of the template:

  searx/templates/simple/icons.html

by the way the icon set (the icon names) has been normalized:

  film-outline   --> film
  magnet-outline --> magnet
  ..
  warning        --> alert

Some missing (categorie) icons had been added.

Some of the ionicons are not suitable for a dark theme, we fixed the svg
manually in src/svg/ionicons:

- #4284 (comment)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42 return42 deleted the web-client-env branch February 28, 2025 11:27
@return42 return42 mentioned this pull request Mar 10, 2025
3 tasks
return42 added a commit to return42/searxng that referenced this pull request Apr 2, 2025
…ort)

In commit 1a3543d in PR-4284 [1] the swiped-events [2] were forgotten to be
migrated.  In this patch, the event library is added to the ``devDependencies``
and imported by::

    import "../../../node_modules/swiped-events/src/swiped-events.js

[1] searxng#4284
[2] https://www.npmjs.com/package/swiped-events

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Reported-by: searxng#4198 (comment)
return42 added a commit that referenced this pull request Apr 3, 2025
…ort)

In commit 1a3543d in PR-4284 [1] the swiped-events [2] were forgotten to be
migrated.  In this patch, the event library is added to the ``devDependencies``
and imported by::

    import "../../../node_modules/swiped-events/src/swiped-events.js

[1] #4284
[2] https://www.npmjs.com/package/swiped-events

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Reported-by: #4198 (comment)
return42 pushed a commit to Bnyro/searxng that referenced this pull request May 22, 2025
The previously used library is unmaintained for 6 years now [1] and the solution
had know issues [2][3]

[1] searxng#4284 (comment)
[2] searxng#4318 (comment)
[3] privau/searxng#56
Bnyro added a commit that referenced this pull request May 22, 2025
The previously used library is unmaintained for 6 years now [1] and the solution
had know issues [2][3]

[1] #4284 (comment)
[2] #4318 (comment)
[3] privau/searxng#56
Bnyro added a commit to Bnyro/searxng that referenced this pull request Jun 25, 2025
The previously used library is unmaintained for 6 years now [1] and the solution
had know issues [2][3]

[1] searxng#4284 (comment)
[2] searxng#4318 (comment)
[3] privau/searxng#56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static files: move source to a dedicated directory.

3 participants