Overview
Zoo Arcadia uses Gulp 5 as its build tool to:- Compile SCSS to CSS
- Minify and bundle JavaScript
- Copy vendor libraries (Bootstrap, jQuery, DataTables)
- Watch files for automatic rebuilds
- Serve the application with BrowserSync for live reload
Build Configuration
The build pipeline is configured ingulpfile.js and package.json.
File Structure
Dependencies
Development Dependencies
Installed vianpm install --save-dev:
- Gulp Core
- JavaScript Processing
- Development Server
- Utilities
package.json
Production Dependencies
UI frameworks and libraries:package.json
Gulp Tasks
Build Tasks
- buildCss - Build CSS
- buildJs - Build JavaScript
- default - Development Mode
Compiles SCSS and copies vendor CSS.Steps:
gulpfile.js
- cleanCss: Delete
public/build/css/ - compileSass: Compile
src/scss/app.scss→public/build/css/app.css - compileBoSidebar: Compile
src/scss/bo-sidebar-only.scss - copyVendorCss: Copy Bootstrap, Normalize, DataTables CSS
File Paths Configuration
Paths are defined at the top ofgulpfile.js:
gulpfile.js
SCSS Compilation
Main Stylesheet
ThecompileSass task processes src/scss/app.scss:
gulpfile.js
- Plumber: Prevents build failures on syntax errors
- BrowserSync Stream: Injects CSS changes without full page reload
Backoffice Sidebar
A separate stylesheet for the admin sidebar:gulpfile.js
Vendor CSS
Copies third-party CSS files:gulpfile.js
JavaScript Processing
Custom JavaScript
Each custom JS file is processed separately with sourcemaps and minification:gulpfile.js
- Allows loading only needed JavaScript per page
- Reduces initial page load time
- Easier debugging with sourcemaps
Vendor JavaScript
Copies pre-minified vendor libraries:gulpfile.js
Development Workflow
Watch Mode
ThewatchAll function monitors files for changes:
gulpfile.js
BrowserSync Server
Starts a development server with live reload:gulpfile.js
-
Start PHP server on port 3001:
-
Run Gulp in another terminal:
-
BrowserSync opens at
http://localhost:3000(proxies to 3001)
Build Commands
Production Build
For production deployments:The Dockerfile automatically runs these commands during the Docker build process.
Cleaning Output
Clean tasks remove compiled files:gulpfile.js
Troubleshooting
SCSS Compilation Fails
SCSS Compilation Fails
Symptoms: Syntax errors or missing importsSolutions:
- Check SCSS syntax in
src/scss/app.scss - Ensure
sasspackage is installed:npm install sass - Look for typos in
@importstatements - Run with verbose output:
npx gulp buildCss --verbose
JavaScript Minification Errors
JavaScript Minification Errors
Symptoms: Terser fails with syntax errorsSolutions:
- Check JavaScript syntax in
src/js/*.js - Ensure ES6+ features are supported by your browser target
- Temporarily disable minification to debug:
BrowserSync Not Working
BrowserSync Not Working
Symptoms: Changes don’t trigger reloadSolutions:
- Ensure PHP server is running on port 3001
- Check proxy URL in
gulpfile.jsmatches your PHP server - Restart Gulp:
Ctrl+Cthennpx gulp - Clear browser cache
Vendor Files Missing
Vendor Files Missing
Symptoms: Bootstrap or jQuery not loadedSolutions:
- Run
npm installto download vendor libraries - Check paths in
gulpfile.jsmatchnode_modules/structure - Manually run:
npx gulp copyVendorCssandnpx gulp copyVendorJs
Node.js Version Issues
Node.js Version Issues
Symptoms: Gulp fails to start or throws errorsSolutions:
- Ensure Node.js 18 or higher:
node --version - Update npm:
npm install -g npm@latest - Clear npm cache:
npm cache clean --force - Delete and reinstall:
rm -rf node_modules && npm install
Advanced Configuration
Custom SCSS Variables
Createsrc/scss/_variables.scss for custom theming:
Adding New JavaScript Files
To add a new JS file:- Create
src/js/my-feature.js - Add to
processJs()ingulpfile.js:
gulpfile.js
- Include in your HTML:
PostCSS and Autoprefixer
For browser prefixes, add PostCSS:gulpfile.js
Next Steps
Environment Setup
Set up your development environment
Architecture Overview
Learn about the application architecture
Docker Deployment
Build assets in Docker
Database Schema
Explore the database structure