| 1 |
const defaults = require('@wordpress/scripts/config/webpack.config'); |
| 2 |
|
| 3 |
/** |
| 4 |
* WDesignKit build config. |
| 5 |
* |
| 6 |
* WordPress.org builds the translation template (POT) with `wp i18n make-pot`, |
| 7 |
* which parses every shipped `.js` file using the Peast JS parser. Our single |
| 8 |
* multi-megabyte minified bundle builds an enormous AST and exhausts make-pot's |
| 9 |
* memory/time budget on WordPress.org — the POT fails and NO JS strings import. |
| 10 |
* |
| 11 |
* Fix (bulletproof, memory-independent): emit the app bundle as `*.min.js`. |
| 12 |
* `make-pot` skips `*.min.js` files by default (hard-coded exclude), so the huge |
| 13 |
* bundle is NEVER parsed. The translatable strings are provided separately in a |
| 14 |
* tiny, readable catalog — build/wdk-i18n-strings.js — generated from src/ by |
| 15 |
* bin/generate-i18n-strings.js right after this build (see the "build" npm |
| 16 |
* script). make-pot parses only that small file (well under a second, a few MB |
| 17 |
* of RAM), so extraction succeeds regardless of WordPress.org's limits. The |
| 18 |
* catalog is enqueued + registered with wp_set_script_translations(), so the |
| 19 |
* per-locale JSON loads every string into the shared wp.i18n store at runtime |
| 20 |
* and the whole React app is translated. |
| 21 |
*/ |
| 22 |
module.exports = { |
| 23 |
...defaults, |
| 24 |
externals: { |
| 25 |
react: 'React', |
| 26 |
'react-dom': 'ReactDOM', |
| 27 |
}, |
| 28 |
output: { |
| 29 |
...defaults.output, |
| 30 |
// App output becomes *.min.js so `wp i18n make-pot` skips it entirely. |
| 31 |
filename: '[name].min.js', |
| 32 |
}, |
| 33 |
performance: { |
| 34 |
hints: false, |
| 35 |
}, |
| 36 |
}; |
| 37 |
|