Successfully modernized the Ventus window manager library from Webpack 4 to Vite 5, updating the build system, dependencies, and module format to use modern JavaScript tooling.
- Replaced Webpack 4 with Vite 5 for faster development and building
- Removed old configuration files:
webpack.config.jswebpack.dev.config.jswebpack.prod.config.jskarma.conf.js(replaced with Vitest).babelrc(Vite handles transpilation natively)
- Updated dependencies to modern versions:
- Vite 5.4.10
- Autoprefixer 10.4.20
- ESLint 9.14.0
- Less 4.2.0
- PostCSS 8.4.47
- Vitest 2.1.4
- Removed outdated dependencies:
- All Webpack-related packages
- Babel packages (no longer needed)
- Karma test runner packages
- Added module exports configuration for both ESM and UMD builds
- Updated scripts for modern development workflow
- Converted all AMD modules to ES6 modules:
src/ventus/core/emitter.jssrc/ventus/core/view.jssrc/ventus/wm/window.jssrc/ventus/wm/windowmanager.jssrc/ventus/wm/modes/default.jssrc/ventus/wm/modes/expose.js
- Updated main entry point (
src/ventus.js) to use ES6 export syntax - Fixed import paths for LESS files and dependencies
- Created
vite.config.jswith:- Library build configuration for UMD and ES module formats
- LESS preprocessing support
- PostCSS with autoprefixer integration
- Source map generation
- Terser minification
- Updated
postcss.config.jsto use ES6 module syntax - Modernized
.eslintrcfor ES2022 and ES modules
- Added
index.htmlfor development testing - Set up modern dev server with hot reloading
- Configured proper alias resolution for internal modules
- Migrated from Karma/Mocha/Chai to Vitest
- Updated test file (
test/window.test.js) to use:- Modern ES6 import syntax
- Vitest's expect API
- Arrow functions instead of function expressions
The modernized build generates:
dist/ventus.js- ES module build (32KB)dist/ventus.umd.cjs- UMD build for legacy compatibility (18KB)dist/style.css- Compiled LESS styles (9.6KB)- Source maps for debugging
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run tests
npm test
# Run tests once
npm run test:run
# Lint code
npm run lint- Faster development - Vite's dev server is significantly faster than Webpack
- Modern tooling - Updated to latest versions of all build tools
- Better tree shaking - ES modules enable better dead code elimination
- Improved DX - Hot module replacement and instant updates
- Future-proof - Uses modern JavaScript standards and tooling
- Smaller bundle size - More efficient bundling with Rollup
- Better debugging - Improved source maps and error reporting
- UMD build maintains compatibility with older module systems
- Library API remains unchanged
- Both CommonJS (
require()) and ES modules (import) are supported
✅ Completed Successfully
- Build system fully migrated to Vite
- All modules converted to ES6
- Development server working
- Production builds generating correctly
- Library maintains full functionality