Skip to content

build: migrate from webpack to vite#1105

Merged
trim21 merged 14 commits into
jesec:masterfrom
trim21:chore/upgrade-vitest-4
May 1, 2026
Merged

build: migrate from webpack to vite#1105
trim21 merged 14 commits into
jesec:masterfrom
trim21:chore/upgrade-vitest-4

Conversation

@trim21

@trim21 trim21 commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrate the frontend build toolchain from webpack to Vite, and Storybook from @storybook/react-webpack5 to @storybook/react-vite. Use @lingui/vite-plugin for i18n catalog compilation instead of @lingui/loader.

Key Changes

Vite Configuration

  • Created vite.config.ts with @vitejs/plugin-react, @lingui/vite-plugin, path aliases (@client, @shared), SCSS/PostCSS, dev server proxy (/apihttp://127.0.0.1:3000), and production build output to dist/assets/
  • Added client/src/vite-env.d.ts for Vite client type declarations
  • Updated client/src/index.html with <script type="module" src="/javascript/app.tsx"> — Vite uses index.html as the entry point instead of a webpack entry config

Build Script

  • Rewrote scripts/build.mjs to use Vite's build() API instead of webpack(). The esbuild server-bundle-with-embedded-assets step is unchanged.

Lingui Integration

  • Catalog imports use ?lingui query parameter (e.g. import {messages} from './strings/en.json?lingui') instead of the webpack loader syntax @lingui/loader!./strings/en.json?raw-lingui
  • Added declare module '*?lingui' in typings.d.ts so TypeScript understands the import shape without @ts-expect-error
  • Updated languages.tsx and .storybook/preview.tsx

Storybook Migration

  • Migrated from @storybook/react-webpack5 to @storybook/react-vite
  • Replaced webpackFinal with viteFinal in .storybook/main.ts: mock aliases via resolve.alias (replaces NormalModuleReplacementPlugin), @lingui/vite-plugin for catalog compilation, SCSS config
  • Removed @storybook/addon-webpack5-compiler-babel addon
  • Updated all story file imports from @storybook/react-webpack5@storybook/react-vite

Asset & Import Changes

  • CountryFlag.tsx: replaced webpack dynamic import() with Vite's import.meta.glob for flag images
  • AboutTab.tsx: raw markdown import uses ?raw suffix instead of webpack raw-loader
  • loadOverlayScrollbars.ts: replaced !raw-loader! inline syntax with ?raw suffix
  • app.tsx: removed webpackPrefetch/webpackPreload magic comments

SCSS

  • Removed ~ prefix from @import 'ress' in style.scss — Vite resolves bare specifiers from node_modules natively
  • Silenced Sass import deprecation in Vite config (ress is a third-party CSS file that can't be converted to @use)

Runtime Fix

  • FloodActions.ts: replaced global.document, global.setTimeout, global.clearTimeout with direct browser APIs — webpack polyfills global as window, Vite doesn't

Deleted Files

  • client/config/webpack.config.dev.mjs
  • client/config/webpack.config.prod.mjs
  • client/scripts/development.mjs
  • client/scripts/development.js
  • client/scripts/utils/ (entire directory)
  • client/config/ (entire directory)

Dependencies

Added: vite, @vitejs/plugin-react, @lingui/vite-plugin, @storybook/react-vite
Removed: webpack, webpack-dev-server, webpackbar, html-webpack-plugin, mini-css-extract-plugin, css-minimizer-webpack-plugin, terser-webpack-plugin, babel-loader, css-loader, postcss-loader, sass-loader, style-loader, source-map-loader, file-loader, raw-loader, case-sensitive-paths-webpack-plugin, eslint-webpack-plugin, @pmmmwh/react-refresh-webpack-plugin, react-refresh, @storybook/builder-webpack5, @storybook/react-webpack5, @storybook/addon-webpack5-compiler-babel, @lingui/loader
Kept: @babel/core, @babel/eslint-parser, @babel/preset-env, @babel/preset-react, @babel/preset-typescript (still used by ESLint's babelParser for .js/.jsx files and by @lingui/cli extraction)

Verification

  • pnpm run check-types passes
  • pnpm run lint passes (0 warnings)
  • pnpm run build produces dist/assets/ (client) and dist/index.js (server with embedded assets)

trim21 added 3 commits May 1, 2026 18:49
…-paths to v6

- vitest: ^2.1.9 -> ^4.1.5
- @vitest/coverage-v8: ^2.1.9 -> ^4.1.5
- vite-tsconfig-paths: ^5.1.4 -> ^6.1.1

Migrate vitest configs for v4 breaking changes:
- Replace removed UserConfigExport type with ViteUserConfigExport
- Replace removed defineWorkspace with plain array export
- Use defineProject instead of defineConfig for workspace projects
@trim21 trim21 changed the title chore: upgrade vitest to v4 build: migrate from webpack to vite May 1, 2026
@trim21 trim21 enabled auto-merge (squash) May 1, 2026 12:46
@trim21 trim21 disabled auto-merge May 1, 2026 12:46
trim21 added 6 commits May 1, 2026 21:15
The default hookTimeout is 10s but constructRoutes in beforeAll can take
longer, especially when spawning torrent client daemons.
Add TorrentStore cleanup to the `cleanupStory` function in `Overview.stories.tsx` to prevent stale data from leaking between stories.
@trim21 trim21 merged commit c7da77e into jesec:master May 1, 2026
23 checks passed
marcinmajsc pushed a commit to marcinmajsc/flood that referenced this pull request May 2, 2026
@trim21 trim21 mentioned this pull request May 8, 2026
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.

1 participant