This document describes the modern build system that replaces the legacy Grunt setup.
# Install dependencies
npm install
# Development mode (with hot reload)
npm run dev
# Build for production
npm run build
# Build only JavaScript
npm run build:js
# Build only CSS
npm run build:css- Vite: Lightning-fast bundler with hot module replacement
- ESLint: Modern JavaScript linting (replaces JSHint)
- Legacy Browser Support: Automatic polyfills for IE11+
- Sass/SCSS: Preprocessor for stylesheets
- PostCSS: Modern CSS processing with autoprefixing
- CSSNano: Production CSS minification
- Autoprefixer: Automatic vendor prefixing
- Prettier: Code formatting for consistency
- Hot Reload: Instant updates during development
- Source Maps: Better debugging experience
| Command | Description |
|---|---|
npm run dev |
Start development server with hot reload |
npm run build |
Build all assets for production |
npm run build:js |
Build only JavaScript files |
npm run build:css |
Build only CSS/SCSS files |
npm run lint |
Lint JavaScript files |
npm run lint:fix |
Lint and auto-fix JavaScript files |
npm run makepot |
Generate translation POT file |
npm run format |
Format code with Prettier |
npm run check-format |
Check code formatting |
├── vite.config.js # Vite configuration
├── .eslintrc.js # ESLint configuration
├── postcss.config.js # PostCSS configuration
├── .prettierrc # Prettier configuration
├── build-css.js # CSS build script
└── package.json # Updated with modern scripts
- Entry Points: Automatically detects and bundles JavaScript files
- Output: Maintains original file structure in
wpsc-admin/js/,wpsc-core/js/, etc. - Legacy Support: Includes polyfills for older browsers
- CSS Processing: Handles SCSS compilation and PostCSS transformations
- WordPress Compatible: Includes WP globals (
wp,ajaxurl, etc.) - jQuery Support: Recognizes jQuery and
$globals - Legacy Code Friendly: Relaxed rules for existing codebase
- Auto-fixable: Many issues can be automatically resolved
- Autoprefixing: Adds vendor prefixes automatically
- Modern CSS: Supports CSS Grid, Flexbox, and modern features
- Minification: Production CSS is automatically minified
- Import Support: Handles CSS imports
- Grunt → Vite (faster, better dev experience)
- JSHint → ESLint (more modern, configurable)
- Browserify → Vite (built-in bundling)
- Uglify → Terser (via Vite, better minification)
- File Structure: Output files go to the same locations
- Functionality: All build tasks produce the same results
- WordPress Compatibility: Still works perfectly with WordPress
- ⚡ Faster Builds: Vite is significantly faster than Grunt
- 🔥 Hot Reload: Instant updates during development
- 📦 Better Bundling: Tree-shaking and optimized chunks
- 🛠 Modern Tools: Up-to-date dependencies and tooling
- 🎯 Better DX: Improved developer experience
- 🔧 More Flexible: Easier to customize and extend
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear Vite cache
rm -rf node_modules/.vite# Auto-fix linting issues
npm run lint:fix
# Check specific files
npx eslint path/to/file.js# Kill any existing dev server
pkill -f vite
# Start fresh
npm run devNote: This modern build system maintains full backward compatibility with your existing codebase while providing significant performance and developer experience improvements.