Configuration file
The Webpack configuration is located at:Entry points
Theme Raed uses multiple entry points to split code by page type, reducing bundle sizes and improving load times:Entry point breakdown
app - Core application bundle
app - Core application bundle
The main application bundle loaded on all pages.Includes:
- Global styles (
app.scss) - Wishlist functionality
- Core JavaScript (
app.js) - Blog functionality
home - Home page scripts
home - Home page scripts
JavaScript specific to the home page.Includes:
- Component initialization
- Slider functionality
- Home page interactions
product-card - Product card component
product-card - Product card component
Reusable product card functionality.Includes:
- Quick add to cart
- Wishlist toggle
- Product card interactions
main-menu - Navigation component
main-menu - Navigation component
wishlist-card - Wishlist item component
wishlist-card - Wishlist item component
Wishlist-specific card functionality.Includes:
- Remove from wishlist
- Move to cart
add-product-toast - Cart notification
add-product-toast - Cart notification
Enhanced add to cart notification component.Includes:
- Toast animation
- Quick cart preview
digital-files - Digital product downloads
digital-files - Digital product downloads
Digital product file management.Includes:
- Download handling
- License display
checkout - Cart and order completion
checkout - Cart and order completion
Shopping cart and thank you page scripts.Includes:
- Cart calculations (
cart.js) - Order confirmation (
thankyou.js)
pages - Special pages
pages - Special pages
Scripts for specific page types.Includes:
- Loyalty program (
loyalty.js) - Brand listing (
brands.js)
product - Product pages
product - Product pages
Product detail and listing page scripts.Includes:
- Product detail page (
product.js) - Product listing page (
products.js)
order - Order tracking
order - Order tracking
Order tracking and history functionality.Usage: Order pages
testimonials - Customer reviews
testimonials - Customer reviews
Testimonials carousel and display.Usage: Pages with testimonials component
Output configuration
Output directory for compiled assetsValue:
/public/Automatically clean the output directory before each buildRemoves old files to prevent accumulation of unused assets
Naming pattern for dynamically loaded chunksPattern:
[name].[contenthash].jsIncludes content hash for cache bustingModule rules
JavaScript/ES6 transpilation
- ES6+ syntax support
- Async/await transformation
- Excludes
node_modulesandtwilight.js - Runtime helpers with regenerator support
SCSS/CSS processing
- sass-loader - Compile SCSS to CSS
- postcss-loader - Apply PostCSS transformations (TailwindCSS, autoprefixer)
- css-loader - Resolve CSS imports and URLs
- MiniCssExtractPlugin.loader - Extract CSS into separate files
The
url: false option prevents css-loader from processing url() references, as assets are handled separately.Plugins
Theme watcher
- Live reload on file changes
- Automatic theme synchronization
- Development server integration
CSS extraction
- Parallel loading of CSS and JS
- Better caching
- Reduced JavaScript bundle size
Asset copying
/src/assets/images/Destination:
/public/images/
Optimization
Array of minimizer plugins
...- Extends default minimizers (Terser for JS)CssMinimizerPlugin- Minifies CSS files
- Removes whitespace and comments
- Optimizes color values
- Merges duplicate rules
- Removes unused declarations
Helper functions
The configuration uses helper functions for path resolution:Build commands
Build commands are typically defined in
package.json.Development build
Production build
Watch mode
Customization
Adding a new entry point
To add a new JavaScript bundle:Adding a new loader
To process additional file types:Excluding files from Babel
To exclude files from transpilation:Performance optimization
Code splitting
Webpack automatically splits code based on entry points. To enable dynamic imports:Bundle analysis
Analyze bundle sizes to identify optimization opportunities:Troubleshooting
Build fails with module not found
Build fails with module not found
Cause: Incorrect path or missing dependencySolution:
- Verify the file exists at the specified path
- Check that all dependencies are installed:
npm install - Clear node_modules and reinstall:
rm -rf node_modules && npm install
CSS not updating
CSS not updating
Cause: Browser cache or build cacheSolution:
- Clear browser cache
- Delete
/public/directory and rebuild - Check that PostCSS config is valid
JavaScript errors in production
JavaScript errors in production
Cause: Babel transpilation issuesSolution:
- Check browser compatibility settings in
@babel/preset-env - Ensure all polyfills are included
- Test in the target browsers
Best practices
- Keep entry points focused - Each entry should serve a specific page or feature
- Minimize dependencies - Only import what you need to reduce bundle size
- Use code splitting - Dynamically import large libraries when needed
- Optimize images separately - Don’t bundle large images through Webpack
- Monitor bundle sizes - Regularly check and optimize bundle sizes
- Use production mode - Always build with
NODE_ENV=productionfor deployment - Enable source maps in development - Easier debugging with readable stack traces
- Cache bust with hashes - Use
[contenthash]in filenames for proper cache invalidation