@10up/build 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +508 -0
- package/bin/10up-build.js +11 -0
- package/config/postcss.config.js +36 -0
- package/dist/build.d.ts +11 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +315 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +103 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +230 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/block-json.d.ts +18 -0
- package/dist/plugins/block-json.d.ts.map +1 -0
- package/dist/plugins/block-json.js +172 -0
- package/dist/plugins/block-json.js.map +1 -0
- package/dist/plugins/copy-assets.d.ts +15 -0
- package/dist/plugins/copy-assets.d.ts.map +1 -0
- package/dist/plugins/copy-assets.js +62 -0
- package/dist/plugins/copy-assets.js.map +1 -0
- package/dist/plugins/sass-plugin.d.ts +17 -0
- package/dist/plugins/sass-plugin.d.ts.map +1 -0
- package/dist/plugins/sass-plugin.js +163 -0
- package/dist/plugins/sass-plugin.js.map +1 -0
- package/dist/plugins/wp-dependency-extraction.d.ts +27 -0
- package/dist/plugins/wp-dependency-extraction.d.ts.map +1 -0
- package/dist/plugins/wp-dependency-extraction.js +306 -0
- package/dist/plugins/wp-dependency-extraction.js.map +1 -0
- package/dist/types.d.ts +540 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/entry-detection.d.ts +13 -0
- package/dist/utils/entry-detection.d.ts.map +1 -0
- package/dist/utils/entry-detection.js +218 -0
- package/dist/utils/entry-detection.js.map +1 -0
- package/dist/utils/externals.d.ts +62 -0
- package/dist/utils/externals.d.ts.map +1 -0
- package/dist/utils/externals.js +152 -0
- package/dist/utils/externals.js.map +1 -0
- package/dist/utils/paths.d.ts +40 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +70 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/watch.d.ts +13 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +214 -0
- package/dist/watch.js.map +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
# @10up/build
|
|
2
|
+
|
|
3
|
+
> Fast esbuild-powered build tool for WordPress block development
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@10up/build` is a modern build tool that provides **10-100x faster builds** than webpack-based alternatives. It's designed as a drop-in replacement for 10up-toolkit's build system, using the same configuration schema while leveraging esbuild's speed.
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
|
|
11
|
+
- **Lightning Fast** - ~150ms builds vs 15-30s with webpack
|
|
12
|
+
- **WordPress Native** - Full support for block.json, script modules, and dependency extraction
|
|
13
|
+
- **Drop-in Compatible** - Uses same `package.json["10up-toolkit"]` configuration
|
|
14
|
+
- **Modern CSS Pipeline** - SCSS + PostCSS + lightningcss
|
|
15
|
+
- **Hot Module Replacement** - React Fast Refresh support for development
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @10up/build --save-dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Production build
|
|
27
|
+
npx 10up-build build
|
|
28
|
+
|
|
29
|
+
# Development with watch mode + HMR
|
|
30
|
+
npx 10up-build start
|
|
31
|
+
|
|
32
|
+
# Watch mode only (no HMR server)
|
|
33
|
+
npx 10up-build watch
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or add scripts to your `package.json`:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "10up-build build",
|
|
42
|
+
"start": "10up-build start",
|
|
43
|
+
"watch": "10up-build watch"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
Configuration is read from `package.json` under the `10up-toolkit` field, maintaining full compatibility with existing 10up-toolkit projects.
|
|
51
|
+
|
|
52
|
+
### Basic Configuration
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"10up-toolkit": {
|
|
57
|
+
"entry": {
|
|
58
|
+
"admin": "./assets/js/admin/admin.js",
|
|
59
|
+
"frontend": "./assets/js/frontend/frontend.js"
|
|
60
|
+
},
|
|
61
|
+
"paths": {
|
|
62
|
+
"blocksDir": "./includes/blocks/",
|
|
63
|
+
"srcDir": "./assets/",
|
|
64
|
+
"copyAssetsDir": "./assets/"
|
|
65
|
+
},
|
|
66
|
+
"useBlockAssets": true,
|
|
67
|
+
"wpDependencyExternals": true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Configuration Options
|
|
73
|
+
|
|
74
|
+
| Option | Type | Default | Description |
|
|
75
|
+
|--------|------|---------|-------------|
|
|
76
|
+
| `entry` | `object` | `{}` | Entry points for scripts and styles |
|
|
77
|
+
| `moduleEntry` | `object` | `{}` | Entry points for ES modules (.mjs output) |
|
|
78
|
+
| `paths.blocksDir` | `string` | `"./includes/blocks/"` | Directory containing block.json files |
|
|
79
|
+
| `paths.srcDir` | `string` | `"./assets/"` | Source directory for assets |
|
|
80
|
+
| `paths.copyAssetsDir` | `string` | `"./assets/"` | Directory for static assets to copy |
|
|
81
|
+
| `paths.globalStylesDir` | `string` | `"./assets/css/globals/"` | Directory for global CSS custom properties |
|
|
82
|
+
| `paths.globalMixinsDir` | `string` | `"./assets/css/mixins/"` | Directory for PostCSS mixins |
|
|
83
|
+
| `paths.blocksStyles` | `string` | `"./assets/css/blocks/"` | Directory for block-specific styles |
|
|
84
|
+
| `useBlockAssets` | `boolean` | `false` | Auto-detect entries from block.json files |
|
|
85
|
+
| `useScriptModules` | `boolean` | `false` | Enable ES module output |
|
|
86
|
+
| `wpDependencyExternals` | `boolean` | `true` | Externalize @wordpress/* packages and generate .asset.php |
|
|
87
|
+
| `loadBlockSpecificStyles` | `boolean` | `false` | Auto-enqueue block-specific stylesheets |
|
|
88
|
+
| `hot` | `boolean` | `false` | Enable Hot Module Replacement |
|
|
89
|
+
| `devServerPort` | `number` | `8887` | Port for HMR WebSocket server |
|
|
90
|
+
| `sourcemap` | `boolean` | `false` | Generate source maps (always on in development) |
|
|
91
|
+
| `externalNamespaces` | `object` | `{}` | Custom package namespaces to externalize |
|
|
92
|
+
|
|
93
|
+
### Configuration Files
|
|
94
|
+
|
|
95
|
+
The build tool respects these configuration files in your project root:
|
|
96
|
+
|
|
97
|
+
| File | Purpose |
|
|
98
|
+
|------|---------|
|
|
99
|
+
| `buildfiles.config.js` | Entry point configuration (alternative to package.json) |
|
|
100
|
+
| `postcss.config.js` | Custom PostCSS configuration |
|
|
101
|
+
| `tsconfig.json` | TypeScript configuration (used by esbuild) |
|
|
102
|
+
|
|
103
|
+
#### buildfiles.config.js
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
module.exports = {
|
|
107
|
+
admin: './assets/js/admin/admin.js',
|
|
108
|
+
frontend: './assets/js/frontend/frontend.js',
|
|
109
|
+
'admin-style': './assets/css/admin/admin-style.scss',
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Block Development
|
|
114
|
+
|
|
115
|
+
### Automatic Entry Detection
|
|
116
|
+
|
|
117
|
+
When `useBlockAssets: true` is enabled, the build tool automatically detects entry points from `block.json` files:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"name": "my-plugin/my-block",
|
|
122
|
+
"editorScript": "file:./index.js",
|
|
123
|
+
"editorStyle": "file:./editor.css",
|
|
124
|
+
"style": "file:./style.css",
|
|
125
|
+
"viewScript": "file:./view.js",
|
|
126
|
+
"viewScriptModule": "file:./view-module.js"
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The tool will:
|
|
131
|
+
1. Find source files (`.ts`, `.tsx`, `.scss` variants)
|
|
132
|
+
2. Compile them to the appropriate output format
|
|
133
|
+
3. Transform the `block.json` to reference compiled files
|
|
134
|
+
4. Generate `.asset.php` files with dependencies
|
|
135
|
+
|
|
136
|
+
### Supported block.json Fields
|
|
137
|
+
|
|
138
|
+
| Field | Output Format | Asset PHP |
|
|
139
|
+
|-------|---------------|-----------|
|
|
140
|
+
| `script` | IIFE (.js) | Yes |
|
|
141
|
+
| `editorScript` | IIFE (.js) | Yes |
|
|
142
|
+
| `viewScript` | IIFE (.js) | Yes |
|
|
143
|
+
| `scriptModule` | ESM (.mjs) | Yes (type: module) |
|
|
144
|
+
| `viewScriptModule` | ESM (.mjs) | Yes (type: module) |
|
|
145
|
+
| `style` | CSS (.css) | No |
|
|
146
|
+
| `editorStyle` | CSS (.css) | No |
|
|
147
|
+
| `viewStyle` | CSS (.css) | No |
|
|
148
|
+
|
|
149
|
+
### block.json Transformation
|
|
150
|
+
|
|
151
|
+
Source files are automatically transformed:
|
|
152
|
+
- `.ts` / `.tsx` → `.js`
|
|
153
|
+
- `.scss` / `.sass` → `.css`
|
|
154
|
+
- A `version` hash is added for cache busting
|
|
155
|
+
|
|
156
|
+
## WordPress Dependency Extraction
|
|
157
|
+
|
|
158
|
+
The build tool automatically externalizes WordPress packages and generates `.asset.php` files.
|
|
159
|
+
|
|
160
|
+
### How It Works
|
|
161
|
+
|
|
162
|
+
1. **Detection**: Imports from `@wordpress/*` packages are detected during bundling
|
|
163
|
+
2. **Externalization**: These imports are marked as external (loaded from WordPress globals)
|
|
164
|
+
3. **Asset Generation**: `.asset.php` files are created with dependency arrays
|
|
165
|
+
|
|
166
|
+
### Output Format
|
|
167
|
+
|
|
168
|
+
**Regular Scripts (IIFE):**
|
|
169
|
+
```php
|
|
170
|
+
<?php return array(
|
|
171
|
+
'dependencies' => array('wp-blocks', 'wp-element', 'wp-i18n'),
|
|
172
|
+
'version' => 'a1b2c3d4e5f6'
|
|
173
|
+
);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**ES Modules:**
|
|
177
|
+
```php
|
|
178
|
+
<?php return array(
|
|
179
|
+
'dependencies' => array('@wordpress/interactivity'),
|
|
180
|
+
'version' => 'a1b2c3d4e5f6',
|
|
181
|
+
'type' => 'module'
|
|
182
|
+
);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Vendor Externals
|
|
186
|
+
|
|
187
|
+
These packages are always externalized:
|
|
188
|
+
|
|
189
|
+
| Package | Global | Handle |
|
|
190
|
+
|---------|--------|--------|
|
|
191
|
+
| `react` | `React` | `react` |
|
|
192
|
+
| `react-dom` | `ReactDOM` | `react-dom` |
|
|
193
|
+
| `react/jsx-runtime` | `ReactJSXRuntime` | `react-jsx-runtime` |
|
|
194
|
+
| `lodash` | `lodash` | `lodash` |
|
|
195
|
+
| `lodash-es` | `lodash` | `lodash` |
|
|
196
|
+
| `moment` | `moment` | `moment` |
|
|
197
|
+
| `jquery` | `jQuery` | `jquery` |
|
|
198
|
+
|
|
199
|
+
### Custom External Namespaces
|
|
200
|
+
|
|
201
|
+
Externalize custom package namespaces (e.g., WooCommerce):
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"10up-toolkit": {
|
|
206
|
+
"externalNamespaces": {
|
|
207
|
+
"@woocommerce": {
|
|
208
|
+
"global": "wc",
|
|
209
|
+
"handlePrefix": "wc"
|
|
210
|
+
},
|
|
211
|
+
"@my-plugin": {
|
|
212
|
+
"global": "myPlugin",
|
|
213
|
+
"handlePrefix": "my-plugin"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
This transforms:
|
|
221
|
+
- `@woocommerce/components` → `wc.components` (global) / `wc-components` (handle)
|
|
222
|
+
- `@my-plugin/utils` → `myPlugin.utils` (global) / `my-plugin-utils` (handle)
|
|
223
|
+
|
|
224
|
+
## CSS Pipeline
|
|
225
|
+
|
|
226
|
+
The CSS pipeline combines multiple tools for maximum compatibility and performance:
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
SCSS → Sass → PostCSS → lightningcss → Output
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### SCSS Support
|
|
233
|
+
|
|
234
|
+
Full Sass/SCSS support with:
|
|
235
|
+
- `@import` and `@use` statements
|
|
236
|
+
- Nested selectors
|
|
237
|
+
- Variables and mixins
|
|
238
|
+
- All Sass features
|
|
239
|
+
|
|
240
|
+
### PostCSS Plugins
|
|
241
|
+
|
|
242
|
+
The following PostCSS plugins are applied:
|
|
243
|
+
|
|
244
|
+
1. **postcss-import** - Inline `@import` statements
|
|
245
|
+
2. **@csstools/postcss-global-data** - Inject global CSS custom properties
|
|
246
|
+
3. **postcss-custom-media** - Transform custom media queries
|
|
247
|
+
4. **postcss-mixins** - CSS mixins support
|
|
248
|
+
|
|
249
|
+
### Global Styles
|
|
250
|
+
|
|
251
|
+
Place global CSS files (custom properties, custom media queries) in `assets/css/globals/`:
|
|
252
|
+
|
|
253
|
+
```css
|
|
254
|
+
/* assets/css/globals/breakpoints.css */
|
|
255
|
+
@custom-media --bp-small (min-width: 600px);
|
|
256
|
+
@custom-media --bp-medium (min-width: 900px);
|
|
257
|
+
@custom-media --bp-large (min-width: 1200px);
|
|
258
|
+
|
|
259
|
+
:root {
|
|
260
|
+
--color-primary: #0073aa;
|
|
261
|
+
--spacing-unit: 8px;
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
These are automatically injected into all stylesheets.
|
|
266
|
+
|
|
267
|
+
### CSS Mixins
|
|
268
|
+
|
|
269
|
+
Place mixin files in `assets/css/mixins/`:
|
|
270
|
+
|
|
271
|
+
```css
|
|
272
|
+
/* assets/css/mixins/typography.css */
|
|
273
|
+
@define-mixin heading {
|
|
274
|
+
font-family: var(--font-heading);
|
|
275
|
+
font-weight: 700;
|
|
276
|
+
line-height: 1.2;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Use in your stylesheets:
|
|
281
|
+
|
|
282
|
+
```css
|
|
283
|
+
.title {
|
|
284
|
+
@mixin heading;
|
|
285
|
+
font-size: 2rem;
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### lightningcss
|
|
290
|
+
|
|
291
|
+
Final CSS processing with lightningcss provides:
|
|
292
|
+
- CSS minification (production only)
|
|
293
|
+
- Vendor prefixing
|
|
294
|
+
- Modern CSS syntax transformation
|
|
295
|
+
- Optimized output
|
|
296
|
+
|
|
297
|
+
## Development Mode
|
|
298
|
+
|
|
299
|
+
### Watch Mode
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
10up-build start
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Features:
|
|
306
|
+
- Fast incremental rebuilds (~50ms)
|
|
307
|
+
- WebSocket server for HMR notifications
|
|
308
|
+
- Automatic browser refresh on changes
|
|
309
|
+
- React Fast Refresh support (placeholder)
|
|
310
|
+
|
|
311
|
+
### HMR Configuration
|
|
312
|
+
|
|
313
|
+
```json
|
|
314
|
+
{
|
|
315
|
+
"10up-toolkit": {
|
|
316
|
+
"hot": true,
|
|
317
|
+
"devServerPort": 8887
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## CLI Reference
|
|
323
|
+
|
|
324
|
+
### Commands
|
|
325
|
+
|
|
326
|
+
| Command | Description |
|
|
327
|
+
|---------|-------------|
|
|
328
|
+
| `10up-build build` | Production build (default) |
|
|
329
|
+
| `10up-build start` | Development mode with HMR |
|
|
330
|
+
| `10up-build watch` | Watch mode without HMR |
|
|
331
|
+
|
|
332
|
+
### Options
|
|
333
|
+
|
|
334
|
+
| Option | Description |
|
|
335
|
+
|--------|-------------|
|
|
336
|
+
| `--help`, `-h` | Show help message |
|
|
337
|
+
| `--version`, `-v` | Show version number |
|
|
338
|
+
| `--hot` | Enable hot reload |
|
|
339
|
+
| `--port=<port>` | HMR server port |
|
|
340
|
+
|
|
341
|
+
## Output Structure
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
dist/
|
|
345
|
+
├── js/
|
|
346
|
+
│ ├── admin.js
|
|
347
|
+
│ ├── admin.asset.php
|
|
348
|
+
│ ├── frontend.js
|
|
349
|
+
│ └── frontend.asset.php
|
|
350
|
+
├── css/
|
|
351
|
+
│ ├── admin-style.css
|
|
352
|
+
│ └── frontend-style.css
|
|
353
|
+
├── blocks/
|
|
354
|
+
│ └── my-block/
|
|
355
|
+
│ ├── block.json
|
|
356
|
+
│ ├── index.js
|
|
357
|
+
│ ├── index.asset.php
|
|
358
|
+
│ ├── editor.css
|
|
359
|
+
│ ├── style.css
|
|
360
|
+
│ ├── view.js
|
|
361
|
+
│ ├── view.asset.php
|
|
362
|
+
│ ├── view-module.mjs
|
|
363
|
+
│ └── view-module.asset.php
|
|
364
|
+
└── images/
|
|
365
|
+
└── (copied static assets)
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## TypeScript Support
|
|
369
|
+
|
|
370
|
+
TypeScript is supported out of the box via esbuild:
|
|
371
|
+
|
|
372
|
+
- `.ts` and `.tsx` files are automatically compiled
|
|
373
|
+
- Type checking is NOT performed (use `tsc --noEmit` separately)
|
|
374
|
+
- `tsconfig.json` paths and settings are respected
|
|
375
|
+
|
|
376
|
+
### Recommended tsconfig.json
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"compilerOptions": {
|
|
381
|
+
"target": "ES2020",
|
|
382
|
+
"module": "ESNext",
|
|
383
|
+
"moduleResolution": "bundler",
|
|
384
|
+
"jsx": "react-jsx",
|
|
385
|
+
"strict": true,
|
|
386
|
+
"esModuleInterop": true,
|
|
387
|
+
"skipLibCheck": true,
|
|
388
|
+
"types": ["@wordpress/blocks", "@types/react"]
|
|
389
|
+
},
|
|
390
|
+
"include": ["assets/**/*", "includes/**/*"]
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Migration from 10up-toolkit
|
|
395
|
+
|
|
396
|
+
### Step 1: Install
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
npm install @10up/build --save-dev
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Step 2: Update Scripts
|
|
403
|
+
|
|
404
|
+
```json
|
|
405
|
+
{
|
|
406
|
+
"scripts": {
|
|
407
|
+
"build": "10up-build build",
|
|
408
|
+
"start": "10up-build start"
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Step 3: Verify Configuration
|
|
414
|
+
|
|
415
|
+
Your existing `10up-toolkit` configuration in `package.json` will work as-is.
|
|
416
|
+
|
|
417
|
+
### Key Differences
|
|
418
|
+
|
|
419
|
+
| Feature | 10up-toolkit | @10up/build |
|
|
420
|
+
|---------|--------------|-------------|
|
|
421
|
+
| Bundler | webpack | esbuild |
|
|
422
|
+
| Build Speed | 15-30s | ~150ms |
|
|
423
|
+
| HMR | webpack-dev-server | WebSocket |
|
|
424
|
+
| CSS Processing | PostCSS | Sass + PostCSS + lightningcss |
|
|
425
|
+
| Bundle Analysis | Built-in | Not yet supported |
|
|
426
|
+
|
|
427
|
+
## Troubleshooting
|
|
428
|
+
|
|
429
|
+
### "Could not resolve @wordpress/*"
|
|
430
|
+
|
|
431
|
+
Ensure `wpDependencyExternals` is enabled:
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"10up-toolkit": {
|
|
436
|
+
"wpDependencyExternals": true
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### "Custom media query --bp-* is not defined"
|
|
442
|
+
|
|
443
|
+
Place your custom media definitions in `assets/css/globals/`:
|
|
444
|
+
|
|
445
|
+
```css
|
|
446
|
+
@custom-media --bp-small (min-width: 600px);
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Source maps not working
|
|
450
|
+
|
|
451
|
+
Enable source maps explicitly:
|
|
452
|
+
|
|
453
|
+
```json
|
|
454
|
+
{
|
|
455
|
+
"10up-toolkit": {
|
|
456
|
+
"sourcemap": true
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### TypeScript errors not shown
|
|
462
|
+
|
|
463
|
+
esbuild doesn't perform type checking. Run TypeScript separately:
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
tsc --noEmit
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## API Reference
|
|
470
|
+
|
|
471
|
+
### Programmatic Usage
|
|
472
|
+
|
|
473
|
+
```javascript
|
|
474
|
+
import { build, watch, loadConfig } from '@10up/build';
|
|
475
|
+
|
|
476
|
+
// Load configuration
|
|
477
|
+
const config = loadConfig();
|
|
478
|
+
|
|
479
|
+
// Run production build
|
|
480
|
+
const result = await build();
|
|
481
|
+
console.log(`Built in ${result.duration}ms`);
|
|
482
|
+
|
|
483
|
+
// Start watch mode
|
|
484
|
+
await watch({ hot: true, port: 8887 });
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Build Result
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
interface BuildResult {
|
|
491
|
+
success: boolean;
|
|
492
|
+
duration: number;
|
|
493
|
+
entries: {
|
|
494
|
+
scripts: number;
|
|
495
|
+
modules: number;
|
|
496
|
+
styles: number;
|
|
497
|
+
};
|
|
498
|
+
errors?: string[];
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## Contributing
|
|
503
|
+
|
|
504
|
+
See the main [10up-toolkit repository](https://github.com/10up/10up-toolkit) for contribution guidelines.
|
|
505
|
+
|
|
506
|
+
## License
|
|
507
|
+
|
|
508
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default PostCSS configuration for 10up-build
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { sync as glob } from 'fast-glob';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
|
|
8
|
+
export default ({ env }) => {
|
|
9
|
+
const globalStylesDir = resolve(process.cwd(), 'assets/css/globals');
|
|
10
|
+
const globalMixinsDir = resolve(process.cwd(), 'assets/css/mixins');
|
|
11
|
+
|
|
12
|
+
const globalCssFiles = glob(`${globalStylesDir}/**/*.css`.replace(/\\/g, '/'));
|
|
13
|
+
const globalMixinFiles = glob(`${globalMixinsDir}/**/*.css`.replace(/\\/g, '/'));
|
|
14
|
+
|
|
15
|
+
const config = {
|
|
16
|
+
plugins: {
|
|
17
|
+
'postcss-import': {},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Add global data plugin if files exist
|
|
22
|
+
if (globalCssFiles.length > 0) {
|
|
23
|
+
config.plugins['@csstools/postcss-global-data'] = {
|
|
24
|
+
files: globalCssFiles,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Add mixins plugin if files exist
|
|
29
|
+
if (globalMixinFiles.length > 0) {
|
|
30
|
+
config.plugins['postcss-mixins'] = {
|
|
31
|
+
mixinsFiles: globalMixinFiles,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return config;
|
|
36
|
+
};
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main build orchestration for 10up-build
|
|
3
|
+
*/
|
|
4
|
+
import { loadConfig, getOutputDir, isProduction } from './config.js';
|
|
5
|
+
import type { BuildConfig, BuildResult } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Main build function
|
|
8
|
+
*/
|
|
9
|
+
export declare function build(customConfig?: Partial<BuildConfig>): Promise<BuildResult>;
|
|
10
|
+
export { loadConfig, getOutputDir, isProduction };
|
|
11
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMrE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAmB,MAAM,YAAY,CAAC;AA+N5E;;GAEG;AACH,wBAAsB,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA+JrF;AAED,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
|