Skip to content

feat!: build with Vite+ and @10up/wp-vite-plugins instead of webpack - #501

Closed
pdavies88 wants to merge 1 commit into
developfrom
feat/vite-engine
Closed

pdavies88 wants to merge 1 commit into
developfrom
feat/vite-engine

Conversation

@pdavies88

@pdavies88 pdavies88 commented Nov 6, 2026 •

Copy link
Copy Markdown

Summary

10up-toolkit 8 builds with Vite+ (Vite 8 + Rolldown) and @10up/wp-vite-plugins instead of webpack. The CLI, the "10up-toolkit" config in package.json and the dist layout stay the same, so most projects upgrade by bumping the version.

Companion PRs: 10up/wp-vite-plugins (feat/toolkit-engine) and 10up/wp-scaffold#333.
https://github.com/10up/wp-vite-plugins/pull/38

Release order: this needs @10up/wp-vite-plugins@1.0.0-alpha.4. package-lock.json still points at alpha.3, so run npm install after alpha.4 is published, before this merges. npm ci fails until then.

How it works

  • build, watch and start call the wp-vite runner from @10up/wp-vite-plugins, which runs vp from the bundled vite-plus. It does a script pass and, when the project has Script Modules, a module pass into one dist/.

  • When the project has no vite.config.*, toolkit passes its own config (config/vite/index.mjs) with --config. That config turns the "10up-toolkit" block into a Vite config. Toolkit hands it the resolved config, CLI flags included, through TENUP_TOOLKIT_CONFIG.

  • Projects can extend the generated config:

    // vite.config.mjs
    import { toolkit } from '10up-toolkit/vite';
    export default toolkit({ server: { port: 5200 } });

What stays compatible

  • Dist paths: entry → dist/js/<name>.js / dist/css/<name>.css. CSS imported by a JS entry → dist/css/<name>.css. filenames.* overrides and -block entry names are honored.
  • Block assets: useBlockAssets discovers assets from block.json, copies block.json and PHP, and writes blocks-manifest.php when useBlockManifest is set. loadBlockSpecificStyles builds to dist/blocks/autoenqueue/. moduleEntry, useScriptModules and --block-modules build Script Modules.
  • .asset.php files for every script and stylesheet.
  • Externals: @wordpress/* imports still work without installing the packages, through uninstalledWordPressPackages: 'external'. wpDependencyExternals: false and --wp=false still turn externals off.
  • JSX in .js files: compiled by a pre plugin before wpExternals sees the code.
  • The default PostCSS stack: global data, mixins, postcss-preset-env at stage 0, and the editor styles wrapper for editor-style.css. A project postcss.config.js still replaces it.
  • Library builds (source / main, -f, -o, -i, --name, --external) go through Vite's library mode.
  • --sourcemap, publicPath / ASSET_PATH, --port.

What changed

  • Hot reloading. start --hot (and the new dev command) starts a Vite dev server. WordPress reaches it through dist/dev-server.php. Toolkit also writes a dist/fast-refresh.php shim that loads it and turns TenUpToolkit\set_dist_url_path() into a no-op, so toolkit 7 PHP keeps working.
  • lint-js / format-js run Oxlint / Oxfmt.
    • Default configs live in config/oxlintrc.json and config/oxfmtrc.json (10up house style).
    • A project's own .oxlintrc.json / .oxfmtrc.json, or a vite.config.*, takes precedence.
    • A project that keeps an ESLint config and installs eslint itself still runs ESLint, so its rules don't change on upgrade.
  • test runs Vitest: jsdom environment, Jest-style globals, jest aliased to vi, and the same file patterns as before. test-unit-jest and test-unit-js are aliases.
  • JSX uses the automatic runtime, so scripts depend on react-jsx-runtime instead of wp-element. WordPress 6.6+ provides it.
  • Node ^22.18.0 || >=24.11.0, the versions Vite+ supports. CI now runs on Node 22 and 24.

Removed

  • webpack, Babel and Jest: every config, plugin and dependency. A project webpack.config.js or babel.config.js is ignored.
  • Linaria and vanilla-extract support. I removed their example blocks from projects/10up-theme.
  • Image and SVG minification, --analyze, --target, --include, core-js polyfills.
  • CSS source maps in production builds. Script maps still work.
  • @10up/eslint-config and @10up/babel-preset-default as peer dependencies. The packages themselves stay in the monorepo.

UPGRADING.md has a "7 to 8" section covering all of this. The README now covers the dev server, the linting setup, testing, and customizing the Vite config. The sections about webpack, BrowserSync, the bundle analyzer and Linaria are gone.

Tests

  • The toolkit's own tests now run on Vitest (vp test): 54 pass.
    • All 9 __tests__/build-project-* fixture suites run a real build.
    • New unit tests cover the generated config (entry mapping, module pass, externals, library mode).
    • I converted the utils tests from Jest mocks to spies on the CommonJS modules.
  • Some assertions changed shape:
    • react-jsx-runtime replaces wp-element.
    • Lightning CSS writes (width>=30em) instead of min-width: 30em.
    • The module and interactivity output assertions use looser regexes.
    • CSS source map assertions are gone.
  • I fixed a malformed block.json fixture, and removed the Linaria and vanilla-extract fixtures.
  • I ran projects/10up-theme, projects/library and projects/library-ts end to end: build, lint, and test for the library. I also checked the dev server: hot file, dev sidecars, JSX served from .js, and cleanup on exit.

Changeset

10up-toolkit: major.

10up-toolkit 8 keeps the CLI, the "10up-toolkit" package.json config and
the dist layout, and swaps the engine underneath:

- build/watch/start run the wp-vite runner from @10up/wp-vite-plugins on
  Vite+ (vp). Toolkit generates the Vite config from package.json
  (config/vite/index.mjs); a project vite.config.mjs can extend it with
  toolkit() from '10up-toolkit/vite'.
- start --hot / dev start a Vite dev server bridged by dist/dev-server.php.
  A dist/fast-refresh.php shim keeps toolkit 7 PHP working.
- JSX in .js files, toolkit's default PostCSS stack, block assets,
  per-block styles in blocks/autoenqueue, Script Modules, library builds
  and uninstalled @wordpress/* externals keep working.
- lint-js and format-js run Oxlint and Oxfmt (ESLint still runs for
  projects that keep an ESLint config); test runs Vitest.
- Remove every webpack, Babel and Jest config and dependency, Linaria and
  vanilla-extract support, image minification and the bundle analyzer.
- Port the toolkit's own tests to Vitest; require Node ^22.18 || >=24.11.

Needs @10up/wp-vite-plugins 1.0.0-alpha.4. Run npm install after it is
published to refresh package-lock.json.
@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ae80b94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
10up-toolkit Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pdavies88
pdavies88 requested a review from fabiankaegy November 6, 2026 02:42
@pdavies88 pdavies88 self-assigned this Nov 6, 2026
@fabiankaegy

Copy link
Copy Markdown
Member

Closing: we're not shipping a Vite-based toolkit 8. Projects move to Vite+ with @10up/wp-vite-plugins directly (see 10up/wp-scaffold#333), and 10up-toolkit is headed for archival.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants