File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import emotion from '@rolldown/plugin-emotion';
66import type { StorybookConfig } from '@storybook/react-vite' ;
77import dsTokenFallbacks from '@wordpress/theme/postcss-plugins/postcss-ds-token-fallbacks' ;
88import dsTokenFallbacksJs from '@wordpress/theme/vite-plugins/vite-ds-token-fallbacks' ;
9+ import { createPostcssBrowserPlugin } from './postcss-browser-plugin.mjs' ;
910import { statusIndexer } from './status-indexer.js' ;
1011
1112/**
@@ -143,6 +144,15 @@ const config: StorybookConfig = {
143144 } ,
144145 ] ,
145146 } ,
147+ optimizeDeps : {
148+ rolldownOptions : {
149+ plugins : [
150+ createPostcssBrowserPlugin (
151+ path . resolve ( import . meta. dirname , '..' )
152+ ) ,
153+ ] ,
154+ } ,
155+ } ,
146156 plugins : [
147157 dsTokenFallbacksJs ( ) ,
148158 react ( ) as PluginOption ,
Original file line number Diff line number Diff line change @@ -7,11 +7,15 @@ const EMPTY_MODULE_ID = '\0postcss-browser-empty';
77// Temporary workaround for https://github.com/vitejs/vite/issues/23512.
88// Remove this plugin and its optimizer registration once the installed Vite
99// version handles browser:false imports without warnings. Keep the Browser
10- // regression test to verify removal.
10+ // regression test and Storybook smoke check to verify removal.
1111//
1212// The separate CSS Modules missing-`from` warning is tracked in:
1313// https://github.com/madyankin/postcss-modules/pull/173
1414// https://github.com/vitejs/vite/issues/15410
15+ /**
16+ * @param {string } rootDir
17+ * @return {import('vite').Plugin } The PostCSS browser import resolver.
18+ */
1519export function createPostcssBrowserPlugin ( rootDir ) {
1620 const require = createRequire (
1721 path . join ( rootDir , 'packages/block-editor/package.json' )
@@ -35,13 +39,15 @@ export function createPostcssBrowserPlugin( rootDir ) {
3539 ) {
3640 return EMPTY_MODULE_ID ;
3741 }
42+ return null ;
3843 } ,
3944 load ( id ) {
4045 if ( id === EMPTY_MODULE_ID ) {
4146 // PostCSS probes these optional APIs. Honor its browser:false
4247 // mappings without Vite's warning-producing external proxies.
4348 return 'module.exports = {};' ;
4449 }
50+ return null ;
4551 } ,
4652 } ;
4753}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { defineConfig } from 'vitest/config';
66import { createVitePlugins } from './config/vite-plugins.mjs' ;
77import { createPlaywrightProvider } from './config/playwright-provider.mjs' ;
88import { createBrowserTraceArtifacts } from './config/browser-traces.mjs' ;
9- import { createPostcssBrowserPlugin } from './config /postcss-browser-plugin.mjs' ;
9+ import { createPostcssBrowserPlugin } from '../../storybook /postcss-browser-plugin.mjs' ;
1010import {
1111 discoverTestFiles ,
1212 getVitestTestsByProject ,
You can’t perform that action at this time.
0 commit comments