Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: doesn't exist at build time, it will remain unchanged to be resolved at runtime #22531

Closed
lvchenyang opened this issue May 12, 2023 · 20 comments · Fixed by #27110
Closed

Comments

@lvchenyang
Copy link

Describe the bug

Build output:

info => Cleaning outputDir: /build
info => Loading presets
info => Building manager..
info => Manager built (121 ms)
info => Copying static files: /Users/lvchenyang/Projects/cya/mintpie-gravitation/common/temp/node_modules/.pnpm/@storybook+manager@7.0.10/node_modules/@storybook/manager/static at /Users/lvchenyang/Projects/cya/mintpie-gravitation/docs/build/sb-common-assets
vite v4.3.5 building for production...

> ./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime

✓ 1501 modules transformed.
build/assets/direction-94a9917f.svg                         1.28 kB │ gzip:   0.71 kB
build/assets/flow-275142c6.svg                              1.39 kB │ gzip:   0.68 kB
build/assets/code-brackets-9ef6443e.svg                     1.46 kB │ gzip:   0.69 kB
build/assets/comments-f15a6837.svg                          1.53 kB │ gzip:   0.70 kB
build/assets/repo-fb4ece47.svg                              1.64 kB │ gzip:   0.83 kB
build/assets/plugin-57148314.svg                            2.17 kB │ gzip:   0.98 kB
build/assets/stackalt-2ad81543.svg                          2.55 kB │ gzip:   1.09 kB
build/assets/colors-ac9401f3.svg                            8.51 kB │ gzip:   3.61 kB
build/iframe.html                                          12.76 kB │ gzip:   3.59 kB
build/assets/AddressEditor.stories-43daeb51.css             0.06 kB │ gzip:   0.08 kB
build/assets/Header-a6911580.css                            0.51 kB │ gzip:   0.31 kB

How to ignore this build error?

When I run rush build in gitlab CI/CD pipeline, this output will cause the pipeline job fail!

image

To Reproduce

No response

System

Environment Info:

  System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v16.20.0/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
  Browsers:
    Chrome: 113.0.5672.92
    Safari: 16.4
  npmPackages:
    @storybook/addon-essentials: ^7.0.10 => 7.0.10 
    @storybook/addon-interactions: ^7.0.10 => 7.0.10 
    @storybook/addon-links: ^7.0.10 => 7.0.10 
    @storybook/blocks: ^7.0.10 => 7.0.10 
    @storybook/builder-vite: ^7.0.10 => 7.0.10 
    @storybook/react: ^7.0.10 => 7.0.10 
    @storybook/react-vite: ^7.0.10 => 7.0.10 
    @storybook/testing-library: ^0.1.0 => 0.1.0

Additional context

main.ts

import type { StorybookConfig } from "@storybook/react-vite";
import { mergeConfig } from "vite";

const config: StorybookConfig = {
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
  ],
  core: {
    builder: "@storybook/builder-vite",
  },
  framework: {
    name: "@storybook/react-vite",
    options: {},
  },
  docs: {
    autodocs: "tag",
  },
  async viteFinal(config) {
    return mergeConfig(config, {
      build: {
        chunkSizeWarningLimit: 4096,
        rollupOptions: {
          onwarn: ({ message }) => {
            if (/Use of eval in/.test(message)) {
              return;
            }
            console.log(message);
          },
        },
      },
    });
  },
};
export default config;
@douglasward
Copy link

I am also getting this error when importing our stylesheet with a relative path in the preview.ts file

@ericclemmons
Copy link
Contributor

Also getting this error. The build seems to work though...

@joseangel-mm
Copy link

I have the same error. It seems the problem is in the iframe.html file (from builder-vite package), in that package, there is no assets folder to get the fonts.
Screenshot 2023-06-28 at 14 00 36

@alb3rtuk
Copy link

Anybody figured out how to fix this?

@MJB52
Copy link

MJB52 commented Aug 22, 2023

This won't help everyone but for anyone using Rush like @lvchenyang - try redeclaring the "build" command in your command-line.json file and add the setting "allowWarningInSuccessfulBuild": true. This will keep warnings from failing your CI/CD builds

    {
      //this command is to override the existing build command to allow warnings in the build
      "commandKind": "bulk",
      "name": "build", 
      "summary": "Build",
      "description": "This command will build projects",
      "safeForSimultaneousRushProcesses": false,
      "enableParallelism": true,
      "ignoreDependencyOrder": false,
      "ignoreMissingScript": true,
      "allowWarningsInSuccessfulBuild": true
    },

@lvchenyang
Copy link
Author

This won't help everyone but for anyone using Rush like @lvchenyang - try redeclaring the "build" command in your command-line.json file and add the setting "allowWarningInSuccessfulBuild": true. This will keep warnings from failing your CI/CD builds

    {
      //this command is to override the existing build command to allow warnings in the build
      "commandKind": "bulk",
      "name": "build", 
      "summary": "Build",
      "description": "This command will build projects",
      "safeForSimultaneousRushProcesses": false,
      "enableParallelism": true,
      "ignoreDependencyOrder": false,
      "ignoreMissingScript": true,
      "allowWarningsInSuccessfulBuild": true
    },

Yep!Add "allowWarningInSuccessfulBuild": true would pass the CI/CD.

@001123
Copy link

001123 commented Dec 25, 2023

Still got this issue, any way to fix it?

@Sinled
Copy link

Sinled commented Feb 9, 2024

Any chances for this to be fixed? or way to silence it without allowing warnings in Rush?

@hc-12
Copy link

hc-12 commented Mar 1, 2024

You might also get this issue if you are importing markdown files.

To fix the issue, you need to change the import:

-import changeLog from './changelog.md`
+import changeLog from './changelog.md?raw`

@h-bessa
Copy link

h-bessa commented Mar 4, 2024

does anybody know how to fix this problem?
@lvchenyang did you find the solution ?

@h-bessa
Copy link

h-bessa commented Mar 4, 2024

PS: I've tried to create my lib using rollup bundler and not vite bundler. it seems to work. No warning, no problem.

@kouts
Copy link
Contributor

kouts commented Mar 13, 2024

This issue still exists in v8, the only workaround I found is to create an sb-common-assets/fonts.css file in the root dir of the project.

@soullivaneuh
Copy link

soullivaneuh commented Mar 15, 2024

The bug occurs also on a fresh new install of storybook:

  1. Run npx storybook@latest init
  2. Select project template React + Vite (TS)
  3. Once installed, run npm run build-storybook

Then you will have the same error on the output.

However, the reported files does exist on the final build folder:

❯ ls -l storybook-static/sb-common-assets
total 204
-rw-rw-r-- 1 sullivan sullivan   675 mars  15 13:24 fonts.css
-rw-rw-r-- 1 sullivan sullivan 49460 mars  15 13:24 nunito-sans-bold-italic.woff2
-rw-rw-r-- 1 sullivan sullivan 47144 mars  15 13:24 nunito-sans-bold.woff2
-rw-rw-r-- 1 sullivan sullivan 49620 mars  15 13:24 nunito-sans-italic.woff2
-rw-rw-r-- 1 sullivan sullivan 47072 mars  15 13:24 nunito-sans-regular.woff2

And apparent issue are coming when you serve the static build.

Here is the env info of the fresh install:

Storybook Environment Info:

  System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm <----- active
    pnpm: 8.14.3 - ~/.local/share/pnpm/pnpm
  Browsers:
    Chrome: 120.0.6099.224
  npmPackages:
    @storybook/addon-essentials: ^8.0.0 => 8.0.0 
    @storybook/addon-interactions: ^8.0.0 => 8.0.0 
    @storybook/addon-links: ^8.0.0 => 8.0.0 
    @storybook/addon-onboarding: ^8.0.0 => 8.0.0 
    @storybook/blocks: ^8.0.0 => 8.0.0 
    @storybook/react: ^8.0.0 => 8.0.0 
    @storybook/react-vite: ^8.0.0 => 8.0.0 
    @storybook/test: ^8.0.0 => 8.0.0 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    storybook: ^8.0.0 => 8.0.0 

@larbimahmoud
Copy link

did any one resolve the error !!

@JoJk0
Copy link

JoJk0 commented Apr 19, 2024

Still having the issue, any workaround?

KelvinOm added a commit to appsmithorg/appsmith that referenced this issue Apr 22, 2024
## Description
- Update Storybook and related dependencies
- Delete the stories for old widget components
- Rewrite stories for new widgets(mdx to tsx)

Note: local chromatic doesn't work because of this
storybookjs/storybook#22531

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced new component stories across various packages to enhance
design system documentation and user experience.

- **Documentation**
- Updated `.gitignore` files to optimize version control settings for
Storybook and build logs.

- **Refactor**
- Modified UI element positioning in Storybook theming for improved
layout management.

- **Style**
- Adjusted CSS properties for the `Select` component to ensure better
visual presentation.

- **Chores**
- Updated dependencies and scripts in package configurations to maintain
up-to-date development tools.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@dohomi
Copy link

dohomi commented Apr 25, 2024

I see this issue on Vite with Storybook v8.0.9 and deploying on Vercel

@julianCast
Copy link

Also having this issue, details:

Info => Copying static files: /Users/me/Documents/GitHub/x/frontend/packages/y/node_modules/@storybook/manager/static at /Users/me/Documents/GitHub/x/frontend/packages/y/storybook-static/sb-common-assets

./sb-common-assets/fonts.css doesn't exist at build time, it will remain unchanged to be resolved at runtime

Could it be because the structure of the project?
Main package with package.json from where we run storybook build command as :
"build-storybook": "yarn storybook build -c ./src/storybook/.storybook"

And then our storybook is in root > src > storybook
The storybook-staticfolder is created in root > storybook-static

Our root package uses gatsby with webpack.

@soullivaneuh

This comment was marked as off-topic.

@valentinpalkovic
Copy link
Contributor

@soullivaneuh You have to run the Storybook build instead of the vite build. The issue still exists. I've just tested it.

@soullivaneuh
Copy link

@valentinpalkovic Indeed! I stupidily ran npm run build cause I use the storybook init command, I was thinking it was for storybook build at this time! Doh!

Running npm run build-storybook makes indeed the error appearing. 🙃

Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.