A calm place to write long-form, and publish it to the open social web.
skypress.blog/
1import { defineConfig } from 'vitest/config';
2
3export default defineConfig( {
4 // @wordpress/* packages guard WordPress-only branches behind these globals.
5 define: {
6 'process.env.IS_GUTENBERG_PLUGIN': 'undefined',
7 'process.env.IS_WORDPRESS_CORE': 'undefined',
8 },
9 test: {
10 globals: true,
11 // jsdom: @wordpress/block-library block registration touches browser globals.
12 environment: 'jsdom',
13 include: [ 'src/**/*.test.ts', 'src/**/*.test.tsx' ],
14 },
15 // Let Vite transform the @wordpress tree instead of Node's native ESM loader,
16 // which rejects their attribute-less JSON imports (e.g. @wordpress/blocks'
17 // `import … from './i18n-block.json'`). One inlined graph also keeps the
18 // @wordpress/data + blocks store singletons consistent for the fidelity tests.
19 //
20 // moment / moment-timezone stay EXTERNAL (native CJS): moment-timezone augments
21 // moment via `require('moment')`, which only lands on @wordpress/date's default
22 // import when both resolve to Node's single CJS instance. Inlining them splits
23 // that instance under Vite's interop → `moment.tz` undefined (Decision 0003).
24 // The Cloudflare build still inlines moment (no native require at the edge);
25 // these configs intentionally differ.
26 ssr: {
27 noExternal: [ /@wordpress\// ],
28 },
29 resolve: {
30 // Mirror astro.config.mjs: collapse the multiply-nested @wordpress store
31 // singletons to one copy each so they register exactly once.
32 dedupe: [
33 'react',
34 'react-dom',
35 '@wordpress/element',
36 '@wordpress/data',
37 '@wordpress/core-data',
38 '@wordpress/notices',
39 '@wordpress/date',
40 '@wordpress/blocks',
41 '@wordpress/block-editor',
42 ],
43 },
44} );