Available npm scripts
The theme provides several npm scripts for different build scenarios:Script details
| Script | Command | Purpose |
|---|---|---|
production | webpack --mode production | Builds optimized assets for production |
prod | webpack --mode production | Alias for production |
development | webpack --mode development | Builds unminified assets for development |
watch | webpack --mode development --watch | Watches files and rebuilds on changes |
Webpack configuration
The webpack configuration inwebpack.config.js handles multiple entry points and asset processing.
Entry points
Theme Raed defines multiple entry points for optimal code splitting:Entry point breakdown
- app: Main application bundle (styles, wishlist, core app, blog)
- home: Homepage-specific JavaScript
- product-card: Product card component logic
- main-menu: Navigation menu functionality
- checkout: Cart and thank you page scripts
- product: Product listing and detail pages
- pages: Loyalty and brands page scripts
Output configuration
- Outputs files to the
publicdirectory - Cleans the output directory before each build
- Uses content hashing for cache busting
Asset processing
JavaScript processing
JavaScript files are processed with Babel for modern browser compatibility:- Transpiles modern JavaScript to ES5
- Excludes node_modules and twilight.js from processing
- Enables async/await support with regenerator runtime
SCSS/CSS processing
Stylesheets are processed through a pipeline:- sass-loader: Compiles SCSS to CSS
- postcss-loader: Processes CSS with PostCSS plugins (Tailwind, autoprefixer)
- css-loader: Resolves CSS imports and URLs
- MiniCssExtractPlugin: Extracts CSS into separate files
PostCSS configuration
Thepostcss.config.js file configures PostCSS processing:
- CSS imports
- Tailwind CSS nesting support
- Future CSS features via postcss-preset-env
Build plugins
MiniCssExtractPlugin
Extracts CSS into separate files instead of inline styles:ThemeWatcher
Monitors theme changes and syncs with Salla platform:CopyPlugin
Copies static assets to the public directory:Optimization
CSS minimization
Production builds minimize CSS with CssMinimizerPlugin:... spread syntax includes webpack’s default minimizers (Terser for JS).
Build workflow
Development build
Production build
Build statistics
Webpack is configured to show concise build statistics:- Asset list sorted by size
- Top 50 assets
- Hides module details for cleaner output
Troubleshooting
Build fails with SCSS errors
Check your SCSS syntax and ensure all imports are valid:JavaScript compilation errors
Babel errors usually indicate syntax issues:Out of memory errors
For large projects, increase Node’s memory limit:Slow builds
To improve build speed:- Use development mode during development
- Only run production builds when necessary
- Consider excluding unnecessary files from webpack processing
Next steps
Customization
Learn how to customize the theme
Preview mode
Test your changes with preview mode