Theme Build
Copied!Shellcd wp-content/themes/aegiscomposer installnpm installnpm run build # Theme blocks → src/Blocks/npm run dev # Watch mode
Output: src/Blocks/ (countdown, slider, slide, toggle, toggle-content, related-posts). These are the theme’s fallback copies; Aegis Dash provides the same blocks.
Video uses WordPress core/video; the player and its editor assets are built in the Aegis Video add-on. For the Aegis Dash build, see Aegis Dash Building Assets.
Plugin Build
Copied!Shellcd wp-content/plugins/aegis-dashnpm installnpm run build # Admin app + the six TypeScript blocks (does not compile Map/Modal)
See Aegis Dash Building Assets.
Build Toolchain
| Tool | Purpose |
|---|---|
@wordpress/scripts | WordPress-specific Webpack configuration |
| Webpack | Module bundler |
| Babel | JavaScript transpilation |
| PostCSS | CSS processing |
| Sass (optional) | CSS preprocessor support |
Available Commands
Production Build
Copied!Shellnpm run build
Creates optimized, minified production-ready assets:
- JavaScript is minified and tree-shaken.
- CSS is minified and autoprefixed.
- Source maps are generated for debugging.
- Asset files include content hashes for cache busting.
Development Build
Copied!Shellnpm run build:dev
Creates unminified development assets:
- No minification (easier to debug).
- Full source maps.
- No content hashes in filenames.
- Faster build time.
Development Watch Mode
Copied!Shellnpm run dev
Starts Webpack in watch mode:
- Watches source files for changes.
- Automatically rebuilds on file save.
- Provides fast incremental builds (only rebuilds what changed).
- Outputs development-friendly (unminified) assets.
- Console output shows build status and errors.
Press Ctrl + C to stop the watcher.
Build Output
Compiled assets are placed in the src/Blocks/ directory (gitignored; run npm run build after clone):
Copied!Directory treesrc/Blocks/├── countdown/├── slider/├── slide/├── toggle/├── toggle-content/├── related-posts/└── blocks-manifest.php
Asset PHP Files
Each compiled JavaScript file generates a companion .asset.php file:
Copied!PHP<?php return array( 'dependencies' => array('wp-element', 'wp-blocks', 'wp-i18n'), 'version' => 'abc123def456',);
This file declares WordPress script dependencies and provides a version hash for cache busting. WordPress uses this during wp_enqueue_script().
Source File Structure
Block source files live in src/Blocks/:
Copied!Directory treesrc/Blocks/├── countdown/│ ├── block.json│ ├── index.tsx│ ├── edit.tsx│ └── view.ts├── slider/├── slide/├── toggle/├── toggle-content/└── related-posts/
Video editor assets are built in the Aegis Video add-on.
Webpack Configuration
Aegis extends the default @wordpress/scripts Webpack config. Entries from block.json file:index.js / file:view.js are remapped to index.tsx / view.ts when those sources exist, then emitted in place under src/Blocks/.
The default configuration handles:
- Block JavaScript compilation (JSX, ES modules).
- CSS extraction and processing.
- Asset copying and hashing.
- WordPress dependency extraction.
CSS Processing
CSS files are processed through PostCSS with the following plugins:
| Plugin | Purpose |
|---|---|
| Autoprefixer | Adds vendor prefixes for browser compatibility |
| postcss-import | Allows @import statements |
| cssnano (production) | Minifies CSS output |
Writing CSS
Aegis stylesheets use standard CSS with CSS custom properties:
Copied!CSS.wp-block-aegis-countdown { display: flex; gap: var(--wp--preset--spacing--md); font-family: var(--wp--preset--font-family--lexend-deca);}
JavaScript Processing
JavaScript is compiled through Babel with WordPress presets:
- JSX transformation for React-based block editor components.
- Modern JavaScript (ES2020+) transpiled for browser compatibility.
- WordPress package externals (wp.element, wp.blocks, and others) are not bundled.
Writing JavaScript
Block scripts use WordPress packages as externals:
Copied!JavaScriptimport { registerBlockType } from '@wordpress/blocks';import { useBlockProps } from '@wordpress/block-editor';registerBlockType( 'aegis/countdown', { edit: Edit, save: Save,} );
Cleaning Build Output
To remove all compiled assets:
Copied!Shellnpm run clean
Or manually delete compiled files under src/Blocks/ (see .gitignore).
Environment Variables
| Variable | Purpose | Default |
|---|---|---|
NODE_ENV | Build mode | production (build) / development (dev) |
SCRIPT_DEBUG | WordPress debug mode | Loads unminified assets |
Troubleshooting
Build Fails with Module Errors
Copied!Shellrm -rf node_modulesnpm installnpm run build
Stale Build Output
Copied!Shellnpm run cleannpm run build
Watch Mode Not Detecting Changes
- Ensure your editor saves files to disk (not just to memory).
- Check that file watchers are not being blocked (increase
fs.inotify.max_user_watcheson Linux). - Restart the watcher.
Translations
The theme catalog is languages/aegis.pot (text domain aegis). It does not include Aegis Dash strings.
Copied!Shellcd wp-content/themes/aegisnpm run translate # Requires `wp` on PATHnpm run translate:studio # WordPress Studio
prepare-translate.js copies vendored Icon, Marquee, Newsletter, Accordion, SVG, Visibility, and Query Loop sources into build/I18nScan for the scan (vendor/ is excluded). Bundled editor.js is not scanned; live SVG inspector strings come from svg-editor.js. WP-CLI scans JavaScript, not TypeScript, so run npm run build first if you changed theme block *.tsx / *.ts sources (for example src/Blocks/slider/edit.tsx, countdown/edit.tsx, toggle/index.tsx, related-posts/edit.tsx). Plugin strings belong in wp-content/plugins/aegis-dash/languages/aegis.pot. Pro strings belong in wp-content/plugins/aegis-pro/languages/aegis-pro.pot. See Aegis Dash Building Assets and Development Tools.
Next Steps
- Development Setup — Complete local setup guide.
- Code Quality — Linting the compiled output.
- Testing — Running tests after building.
- Deployment — Deploying built assets to production.