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.

CSS Loader for codemirror.css

See original GitHub issue

This issue pertains to:

  • GraphQL Playground React Component

What OS and OS version are you experiencing the issue(s) on?

macOS

What version of graphql-playground(-electron/-middleware) are you experience the issue(s) on?

^1.2.0

What is the expected behavior?

I can decide how to load CSS myself/given instructions on how to set up my react app to work with this lib

What is the actual behavior?

Codemirror css is imported inside the module, so I can’t load it in a way that works with next.js

Maybe document what loader is recommended to make this file load? I have a workaround to load it in next.js, so I can load the playground css via import playgroundCSS from 'graphql-playground/playground.css' and inline it, but since the codemirror css is imported somewhere inside this lib, it’s out of my control.

What steps may we take to reproduce the behavior?

  1. create a directory
  2. add next yarn add next react react-dom
  3. create file in pages folder ./pages/index.js with contents:
import React from 'react'
import Playground from 'graphql-playground'
export default = () => <Playground endpoint={'/graphql'} />
  1. error:
Error in codemirror/lib/codemirror.css
Module parse failed: /Users/.../frontend-admin/node_modules/codemirror/lib/codemirror.css Unexpected token (3:0) You may need an appropriate loader to handle this file type. | /* BASICS */ | | .CodeMirror { | /* Set height, width, borders, and global font properties here */ | font-family: monospace;

tl:dr You may need an appropriate loader to handle this file type.

this will do all the steps for you (bash)

mkdir graphql-playground-issue-279 &&\
cd graphql-playground-issue-279 &&\
yarn init -y &&\
yarn add next react react-dom &&\
mkdir pages &&\
touch pages/index.js &&\\n
echo "import React from 'react'\\n
import Playground from 'graphql-playground'\\n
export default = () => <Playground endpoint={'/graphql'} />\
" >> pages/index.js &&\
./node_modules/.bin/next dev

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
albinekbcommented, Jun 1, 2018

Well done!

1reaction
huv1kcommented, Jun 1, 2018

Everything it’s now inside styled-components

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Help] Running into loader-related issue when trying to use ...
Hi, I'm just starting out with programming and trying to implement CodeMirror into a Javascript React project I'm working on.
Read more >
Module parse failed codemirror.css You may need an ... - GitHub
Module parse failed codemirror.css You may need an appropriate loader to handle this file type. #34.
Read more >
CodeMirror does not work with React/Webpack - Stack Overflow
Yes, it's an actual answer. You should just import some codemirror's css in your entrypoint file as it did in the example import...
Read more >
Developer Guide - Vue Styleguidist
How it works; Webpack loaders and Webpack configuration; React components; Styles ... loaders/css-loader!codemirror/lib/codemirror.css').
Read more >
CodeMirror: User Manual
CodeMirror is a code-editor component that can be embedded in Web pages. ... You must make sure the CSS file defining the corresponding...
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