React-pdf: Request: Don't enforce the use of a CSS loader

Created on 25 Jan 2018  ·  3Comments  ·  Source: wojtekmaj/react-pdf

Might be related to #133. It seems with the newer versions of react-pdf, you get this error when you don't have a CSS loader:

ERROR in ./node_modules/react-pdf/build/annotation_layer_builder.css
Module parse failed: Unexpected token (16:0)
You may need an appropriate loader to handle this file type.
|  */
| 
| .annotationLayer section {
|   position: absolute;
| }
 @ ./node_modules/react-pdf/build/PageAnnotations.js 35:0-41
 @ ./node_modules/react-pdf/build/Page.js
 @ ./node_modules/react-pdf/build/entry.noworker.js
 @ ./src/features/preview/components/Preview.js
 @ ./src/features/preview/components/index.js
 @ ./src/app/pages/Generator.js
 @ ./src/app/App.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server babel-polyfill ./index.js

This is a bit inconvenient for a couple reasons:

  1. Annotations aren't rendered because I have renderAnnotations={false}, which makes it a bit strange that its still trying to use this CSS
  2. People who use css in js solutions like styled-components don't really need to use CSS loaders, so it's a bit annoying to have to include it just for this package.

Just my thoughts on this, feel free to close this out if its too similar to #133 or if you don't want to remove this behavior.

enhancement help wanted

Most helpful comment

My dream is to make React-PDF as close to zero-config as possible.

Removing the CSS import entirely was a last resort for me, but I did it in the newest (pre)release - v3.0.0-alpha.3. Let me know what you think!

All 3 comments

That's a very good request I think. I don't quite know how to get around this problem yet, but I'll keep it in mind!

Isn't it a idea to not include the css inside the PageAnnotations component? But if you want it that you can load it your self?

That way you can also provide a JSS one that people like me can load.

My dream is to make React-PDF as close to zero-config as possible.

Removing the CSS import entirely was a last resort for me, but I did it in the newest (pre)release - v3.0.0-alpha.3. Let me know what you think!

Was this page helpful?
0 / 5 - 0 ratings