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.

Error using tagged template literal styles with gatsby-plugin-astroturf

See original GitHub issue

Happy to move this question somewhere else if this isn’t the appropriate place, but I didn’t see any issues or activity in the gatsby-plugin-astroturf repository, so figured I’d start here.

I’m trying to use astroturf with gatsby, and it seems to be configured correctly for general use, but I ran into a problem when attempting to add tags to a block of template literal CSS, and wondered if anyone here might’ve run into a similar issue, as I can’t seem to figure out how to fix it (if it can be fixed).

Default Gatsby project template, trying to create a basic component that imports an image from a local file, which converts it to a data uri. Trying to dynamically add that data uri as the url value for a background-image property like this:

const myImageUrl = "data:image/svg+xml;base64,PCEtLSBCeSBTYW0gSGVyYmVy…0ZSIgLz4KICAgIDwvY2lyY2xlPgogIDwvZz4KPC9zdmc+Cg=="

const styles = css`
  .loadingIndicator {
    align-items: center;
    display: flex;
    height: auto;
    margin: 0;
    transition: all 0.5s;

    &::before {
      background-image: url(${myImageUrl});
      background-size: contain;
      border: 1px dashed #eee;
      content: "";
      display: block;
      height: 1.5rem;
      margin-right: 0.5rem;
      text-indent: -625rem;
      width: 1.5rem;
    }

    &[style*="display: none;"] {
      height: 0;
      opacity: 0;
      padding: 0;
      pointer-events: none;
      user-select: none;
      visibility: visible;
    }
  }

  .label {
    margin: 0;
  }
`

When gatsby attempts to compile that, I get the following error:

success Re-building development bundle - 0.262s
success extract queries from components - 0.045s

 ERROR #98123  WEBPACK

Generating development JavaScript bundle failed

/Users/me/projects/my/project/name/src/components/loading-indicator/index.js: Cannot read property 'name' of undefined

File: src/components/loading-indicator/index.js

failed Re-building development bundle - 0.212s

 ERROR

UNHANDLED REJECTION Cannot read property 'find' of undefined



  TypeError: Cannot read property 'find' of undefined

  - loader.js:190 dependencies.push.buildDependency.then.module
    [my-project-name]/[astroturf]/loader.js:190:35

  - next_tick.js:68 process._tickCallback
    internal/process/next_tick.js:68:7

This is my gatsby-config.js, after I added astroturf, gatsby-plugin-astroturf, gatsby-plugin-postcss and postcss-nested as dependencies to the project:

module.exports = {
  siteMetadata: {
    title: "My Project Name",
    description: "My Project Description",
    author: "@ryexley"
  },
  plugins: [
    "gatsby-plugin-react-helmet",
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "images",
        path: `${__dirname}/src/images`
      }
    },
    "gatsby-transformer-sharp",
    "gatsby-plugin-sharp",
    {
      resolve: "gatsby-plugin-manifest",
      options: {
        name: "gatsby-starter-default",
        short_name: "starter", // eslint-disable-line camelcase
        start_url: "/", // eslint-disable-line camelcase
        background_color: "#663399", // eslint-disable-line camelcase
        theme_color: "#663399", // eslint-disable-line camelcase
        display: "minimal-ui",
        icon: "src/images/gatsby-icon.png" // This path is relative to the root of the site.
      }
    },
    {
      resolve: "gatsby-plugin-postcss",
      options: {
        postCssPlugins: [
          require("postcss-nested")({})
        ]
      }
    },
    "gatsby-plugin-astroturf"
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ]
}

Anyone here have any idea what might be causing this? Maybe I’m doing something wrong here. This is my first time trying to use astroturf, so I’m still trying to figure it all out. Any help would be greatly appreciated, thanks!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ryexleycommented, Apr 19, 2021

@Sandy-Garrido I did not. Sorry. Got no reply, and never found a workaround.

0reactions
Sandy-Garridocommented, Apr 19, 2021

Hey @ryexley did you ever solve this issue? I don’t suppose that if you did, you’d remember it? tia

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error using tagged template literal styles with gatsby-plugin ...
I'm trying to use astroturf with gatsby, and it seems to be configured correctly for general use, but I ran into a problem...
Read more >
21 Using template literals and tagged templates - Exploring JS
Before we dig into the two features template literal and tagged template, let's first examine the multiple meanings of the term template.
Read more >
Bridging the Gap Between CSS and JavaScript: CSS-in-JS
In this article, we're going to dig into the concept of CSS-in-JS. ... tagged template literals instead of objects to look more like...
Read more >
rvi - River Thames Conditions - Environment Agency - GOV.UK
Zmule atnaujinimai, I'm coming home lebron, Ziua in care vom murii, Reactable dj table, Tony robbins rpm pdf, Liquipedia league, South korean buddhism, ......
Read more >
The Most Popular CSS-in-JS Libraries in 2022 - Stack Diary
CSS-in-JS is a popular approach to styling web applications that ... template literal syntax that allows you to write CSS styles using the ......
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