Open ciepol opened 1 month ago
Disclaimer This information might be inaccurate, due to it being generated automatically
To resolve the issue with postcss-url
plugin inlining assets, follow these steps:
Update base-webpack.config.ts
:
/code/builders/builder-webpack5/src/preview/base-webpack.config.ts
.hasPostcssAddon
check correctly identifies the PostCSS addon:
const hasPostcssAddon = options.presetsList?.some((preset) =>
/@storybook(\/|\\)addon-postcss/.test(typeof preset === 'string' ? preset : preset.name)
);
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
type: 'asset/inline',
}
Modify addon-postcss.ts
:
/code/lib/cli/src/automigrate/fixes/addon-postcss.ts
.Test Configuration:
/code/lib/cli/src/automigrate/fixes/addon-postcss.test.ts
correctly validates the presence of @storybook/addon-postcss
.These changes should address the issue with inlining assets using the postcss-url
plugin.
/code/lib/cli/src/automigrate/fixes/addon-postcss.ts /code/lib/cli/src/automigrate/fixes/addon-postcss.test.ts /code/builders/builder-webpack5/src/preview/base-webpack.config.ts /code/lib/core-webpack/package.json /code/lib/source-loader/README.md
I'm facing a similar issue, but with Vite instead of Webpack
[build:watch] [storybook] Sourcemap for "/virtual:/@storybook/builder-vite/setup-addons.js" points to missing source files
[build:watch] [storybook] C:\src\core\node_modules\storybook\bin\index.cjs:23
[build:watch] [storybook] throw error;
[build:watch] [storybook] ^
[build:watch] [storybook]
[build:watch] [storybook] TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received 'C:\\src\\core\\\x00\\sb-common-assets\\nunito-sans-regular.woff2'
[build:watch] [storybook] at Object.access (node:fs:227:10)
[build:watch] [storybook] at C:\src\core\node_modules\postcss-url\src\lib\get-file.js:21:12
[build:watch] [storybook] at new Promise (<anonymous>)
[build:watch] [storybook] at existFileAsync (C:\src\core\node_modules\postcss-url\src\lib\get-file.js:20:12)
[build:watch] [storybook] at C:\src\core\node_modules\postcss-url\src\lib\get-file.js:32:20
[build:watch] [storybook] at Array.map (<anonymous>)
[build:watch] [storybook] at C:\src\core\node_modules\postcss-url\src\lib\get-file.js:31:36
[build:watch] [storybook] at new Promise (<anonymous>)
[build:watch] [storybook] at findExistsPath (C:\src\core\node_modules\postcss-url\src\lib\get-file.js:30:12)
[build:watch] [storybook] at getFile (C:\src\core\node_modules\postcss-url\src\lib\get-file.js:61:12)
[build:watch] [storybook] at processCopy (C:\src\core\node_modules\postcss-url\src\type\copy.js:57:12)
[build:watch] [storybook] at C:\src\core\node_modules\postcss-url\src\lib\decl-processor.js:67:9
[build:watch] [storybook] at process (C:\src\core\node_modules\postcss-url\src\lib\decl-processor.js:95:16)
[build:watch] [storybook] at replaceUrl (C:\src\core\node_modules\postcss-url\src\lib\decl-processor.js:111:25)
[build:watch] [storybook] at C:\src\core\node_modules\postcss-url\src\lib\decl-processor.js:139:35
[build:watch] [storybook] at String.replace (<anonymous>) {
[build:watch] [storybook] code: 'ERR_INVALID_ARG_VALUE'
[build:watch] [storybook] }
[build:watch] [storybook]
[build:watch] [storybook] Node.js v20.14.0
[build:watch] [storybook] npm run storybook exited with code 7
Describe the bug
When using
PostCSS
plugin (postcss-url) to inline assets using base64 encoding inurl()
error pops up duringstorybook
start:Feels like the issue has been introduced while doing https://github.com/storybookjs/storybook/pull/27110
Reproduction link
https://stackblitz.com/edit/github-txbnpe-gdeiug?file=postcss.config.js
Reproduction steps
PostCSS
configuration inpostcss.config.js
:/* @type {import('postcss-load-config').Config} / const config = { extract: false, inject: true, plugins: [ url({ url: 'inline', }), ], sourceMap: true, };
export default config;
Additional context
No response