Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to load minified css #160

Closed
EmaSuriano opened this issue Jul 20, 2018 · 9 comments
Closed

Error when trying to load minified css #160

EmaSuriano opened this issue Jul 20, 2018 · 9 comments

Comments

@EmaSuriano
Copy link

EmaSuriano commented Jul 20, 2018

Bug Report

Describe the bug
I'm using a library (react-tippy) which requires to load a css file in order to look as expected. When I load the component which imports that css file, I get an error of Unexpected token .*

A clear and concise description of what the bug is.
I get the following error on the console which stops the server from starting ..

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .tippy-touch{cursor:pointer!important}.tippy-notransition{transition:none!important}.tippy-popper{max-width:400px;-webkit-perspective:800px;perspective:800px;z-index:9999;outline:0;transition-timing-function:cubic-bezier( ...

To Reproduce

In order to

  1. git clone https://github.com/EmaSuriano/docz-css-bug-example.git
  2. yarn install
  3. yarn dev

Expected behavior

Start the server as expected.
screen shot 2018-07-20 at 19 11 11

Enviroment

  • OS: OSX
  • Node/npm version: 10.6.0

Additional context/Screenshots

The workaround I found was to format the file with prettier and it seems the server to be working. The problem with is that I have to store the file in my codebase, which I really don't want to do because if the owner of the library made a change on the styles I have to manually change it ..

This is the branch with the work around --> https://github.com/EmaSuriano/docz-css-bug-example/tree/formatting-css-file

@tsnolan23
Copy link

@EmaSuriano The docz CSS plugin should resolve your problem:

https://github.com/pedronauck/docz/tree/master/packages/docz-plugin-css

@EmaSuriano
Copy link
Author

Hi @tsnolan23 I'm using the docz-plugin-css. This my doczrc.js

// doczrc.js
import { css } from 'docz-plugin-css';

export default {
  plugins: [
    css({
      preprocessor: 'postcss',
      cssmodules: true,
    }),
  ],
};

Please tell me if I'm missing anything

@tsnolan23
Copy link

@EmaSuriano I was able to get your project running by modifying the bundler config without the CSS plugin:

// doczrc.js
export default {
  modifyBundlerConfig: config => {
    config.module.rules.push({
      test: /\.css$/,
      use: ["style-loader", "css-loader"]
    });
    return config;
  }
};

It did require additional dependencies, then, though - style-loader and css-loader.

Not sure if that's the proper way to achieve the result, but it does work!

@EmaSuriano
Copy link
Author

It works! 🎉
But I'm thinking if this bug should be fixed in docz-plugin-css because this kind of transformation should be taking care of by this plugin ...

@tsnolan23
Copy link

Yeah, not disagreeing with that!

@pedronauck
Copy link
Member

Fixed on v0.7.0

@EmaSuriano
Copy link
Author

Hi @pedronauck, I updated the version of docz and docz-plugin-css to 0.7.0 and the problem still persists :( This is the repo, could you please check it out?

@pedronauck pedronauck reopened this Jul 24, 2018
@pedronauck
Copy link
Member

pedronauck commented Jul 24, 2018

Sorry @EmaSuriano, I was excluding imports from node_modules at loaders 🙄 Now I think that is fixed on v0.7.1 🙏

@ekafyi
Copy link

ekafyi commented Sep 3, 2018

@tsnolan23's fix here #160 (comment) works for me, in case others are browsing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants