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.

Vanilla Extract Component Library + Gatsby

See original GitHub issue

Describe the bug

I’ve been trying to write a components library based on Vanilla Extract and then consume the components on one of my Gatsby projects.

The problem is that on the consumer side, I’m getting the (in)famous error:

Styles were unable to be assigned to a file. This is generally caused by one of the following: 
- You may have created styles outside of a '.css.ts' context 
- You may have incorrect configuration. See https://vanilla-extract.style/documentation/setup

Link to reproduction

Components Library Gatsby Project

Steps to reproduce

  1. Clone the gatsby project
  2. npm install
  3. npm start
  4. in your preferred browser, visit localhost:8000

System Info

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Memory: 2.08 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  npmPackages:
    @vanilla-extract/babel-plugin: ^1.1.2 => 1.1.2 
    gatsby: ^4.1.1 => 4.1.1 
    react: ^17.0.1 => 17.0.2 
    react-dom: ^17.0.1 => 17.0.2 
    vanilla-extract-components: github:RaulEscobarRivas/vanilla-extract-components => 0.0.1 

Disclaimer

I’m not entirely sure if this is a problem with Vanilla Extract or my components library setup, but I couldn’t find any components library out there using vanilla extract as base, so apologies in advance if this is unrelated!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
joaogarincommented, Sep 19, 2022

Facing the same error but with a different setup I’m using Vanilla + Vite + Storybook

I created the issue here https://github.com/seek-oss/vanilla-extract/issues/835 I have the same problem. Started a vite storybook as documented in https://storybook.js.org/blog/storybook-for-vite/ and then added Vanilla extract

Edit :

FYI @madebydor I found the aswer, posted the answer in the issue mentioned above. The trick was to add :

 async viteFinal(config) {
    return mergeConfig(config, {
      plugins: [require("@vanilla-extract/vite-plugin").vanillaExtractPlugin()],
    });
  },

At the end of the main.js file in the .storybook folder

1reaction
madebydorcommented, Sep 16, 2022

Facing the same error but with a different setup I’m using Vanilla + Vite + Storybook

Any solution?

image
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vanilla Extract Component Library + Gatsby · Issue #458
I've been trying to write a components library based on Vanilla Extract and then consume the components on one of my Gatsby projects....
Read more >
gatsby-plugin-vanilla-extract
gatsby -plugin-vanilla-extract. Gatsby plugin which wraps the vanilla-extract project for easy use in Gatsby. Setup.
Read more >
Gatsby - Vanilla Extract
Gatsby. A plugin for integrating vanilla-extract with Gatsby. Installation.
Read more >
@vanilla-extract/css-utils examples - CodeSandbox
Learn how to use @vanilla-extract/css-utils by viewing and forking example apps that make use of @vanilla-extract/css-utils on CodeSandbox. ; vanilla-extract- ...
Read more >
vanilla-extract/css NPM
To add to your Gatsby site, use the gatsby-plugin-vanilla-extract plugin. Rollup. Note: This option is useful for library development but not suitable for ......
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