question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Rollup plugin working locally but not on static build

See original GitHub issue

Describe the bug

We use Storybook with Lit. In our Lit components, we import SCSS files.

import { html, LitElement } from "lit";
import style from "./quote-block.scss";

@customElement("component-name")
export class ComponentName extends LitElement {
  static get styles() {
    return [ style ];
  }
}
...

To import SCSS and not need to wrap all our imported styles in the unsafeCSS() function from Lit, we use a plugin in our Vite config - rollup-plugin-postcss-lit. I’ve also added this plugin to main.js in Storybook.

image

Components render as expected with start-storybook, but the components do not render when using build-storybook and viewing the resulting static pages. We are met with console errors:

image

Environment

  • Node.js version: [e.g. v14.19.1]
  • NPM version: [e.g. 6.14.16]

Additional context

Because the plugin works with a dev server, and after not finding an answer in other repos, I am hoping someone here can provide some insight into why this would be happening, thank you.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
troyvassalotticommented, Apr 22, 2022

Hey @IanVS! Thanks for the quick response. I can clarify a bit on this:

  1. We went from webpack to vite - both with Lit - and it was working prior because we used lit-scss-loader. The rollup plugin we want to use has a similar goal.
  2. Everything else with our build works as intended. The start-storybook preview shows our expected results; it is only the build-storybook result that doesn’t seem to take the plugin into account.
  3. Neither adding framework: "@storybook/web-components" or ?inline address the issue.

I got a very simple local branch example that gives the same result (sans the console error it seems, but the lack of styles does continue) and I would be happy to submit a PR for it in a few.

0reactions
IanVScommented, Apr 22, 2022

Thanks @troyvassalotti! I left a comment in the PR, but for anyone following along here, this is an issue with an incompatibility between the default include picomatch of the plugin, vs the filenames that vite generates (which can include a query param). I’m going to close this issue since there’s a workaround, and the main issue is not in this package, but I’m glad you stopped by, and I’m excited to have a lit example in our repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

rollup-plugin-multi-entry (virtual) does not work with dev server
When running the dev server, however, it fails to resolve /static/virtual:aleksis-local-full.js and throws a 404 error. My current guess is that ...
Read more >
rollup.js
js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
This week, we're going to build our first project using Rollup, which is a build tool for bundling JavaScript (and stylesheets, but we'll...
Read more >
Tsdx - rollup-plugin-static-files subfolder - Stack Overflow
I'm building a module using tdsx that implements rollup as a bundler . I have this structure: dist node_modules src templates index.ts.
Read more >
@rollup/plugin-commonjs - npm
Rollup with @rollup/plugin-node-resolve resolves modules to their real paths by default. So include and exclude paths should handle real paths ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found