@web-engine-dev/build
Build orchestration for game projects with multi-platform targets.
Features
- Multi-Platform: Web, mobile, desktop targets
- Build Configs: Development, production, staging
- Code Bundling: Tree-shaking, minification
- Asset Processing: Integrated asset pipeline
- Environment Config: Per-target settings
Installation
bash
npm install @web-engine-dev/build
# or
pnpm add @web-engine-dev/buildQuick Start
typescript
import { GameBuilder } from '@web-engine-dev/build';
const builder = new GameBuilder({
entry: './src/main.ts',
outDir: './dist',
targets: ['web', 'pwa', 'electron'],
});
// Development build
await builder.build('development');
// Production build
await builder.build('production');API Overview
Build Configuration
typescript
const config = {
entry: './src/main.ts',
outDir: './dist',
targets: ['web', 'pwa'],
development: {
sourceMaps: true,
minify: false,
hotReload: true,
},
production: {
sourceMaps: false,
minify: true,
splitChunks: true,
},
};CLI Usage
bash
# Development build
npx web-engine build --mode development
# Production build
npx web-engine build --mode production
# Specific target
npx web-engine build --target pwa --mode production
# Watch mode
npx web-engine build --watchTarget-Specific Config
typescript
const config = {
targets: {
web: {
publicPath: '/',
outputFormat: 'esm',
},
pwa: {
manifest: './manifest.json',
serviceWorker: true,
},
electron: {
nodeIntegration: true,
preloadScript: './preload.js',
},
},
};Environment Variables
typescript
// .env.development
GAME_SERVER_URL=http://localhost:3000
DEBUG=true
// .env.production
GAME_SERVER_URL=https://api.game.com
DEBUG=false
// Access in code
const serverUrl = import.meta.env.GAME_SERVER_URL;