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

Transform css module imports during build #126

Merged
merged 1 commit into from
Aug 8, 2017
Merged

Transform css module imports during build #126

merged 1 commit into from
Aug 8, 2017

Conversation

danny-andrews
Copy link
Collaborator

@danny-andrews danny-andrews commented Jul 17, 2017

This changeset transforms css module imports as part of the build process.

Fixes #80 and #28 and possibly #84.

@danny-andrews
Copy link
Collaborator Author

@roylee0704 Getting a VersionEye error for an existing dependency.

@roylee0704
Copy link
Owner

roylee0704 commented Jul 31, 2017

@silvenon what do you think about this?

@roylee0704 roylee0704 requested a review from silvenon July 31, 2017 15:09
@nigelterry
Copy link

This fixed #28 for me.

@roylee0704 roylee0704 merged commit c881e38 into roylee0704:master Aug 8, 2017
@roylee0704
Copy link
Owner

Thanks for the PR @danny-andrews ;)

@roylee0704
Copy link
Owner

@danny-andrews Is everything working on your side? v1.1.4

@danny-andrews
Copy link
Collaborator Author

@roylee0704 Haven't pulled down the new version yet. I'll let you know when we have!

@slavab89
Copy link

For me this actually breaks (v1.1.4)
My config (for Dev) is as follows (Will be happy to know what to change)

In components:

import { Row, Col } from 'react-flexbox-grid/lib/index';

Webpack:

{
  test: /\.css$/,
  use: [
    { loader: 'style-loader' }, 
    { loader: 'css-loader', options: importLoaders: 1, modules: true }, // With additional options
    { loader: 'postcss-loader' }], // With additional options
  ],
  include: './app/css', //my own css files are here
  exclude: /flexboxgrid/
},
{
  test: /\.css$/,
  use: [
    { loader: 'style-loader' },
     { loader: 'css-loader', options: modules: true }
  ],
  include: /flexboxgrid/
}

I've tried to change the import to just import { Row, Col } from 'react-flexbox-grid' and add import 'flexboxgrid/dist/flexboxgrid.css' but it doesnt help.
It seems that it does create different classNames for row, col but the file itself with the rules is not present therefore no styles are actually applied.

@danny-andrews
Copy link
Collaborator Author

danny-andrews commented Aug 10, 2017

@slavab89 It's probably easier to add 'flexboxgrid/dist/flexboxgrid.css' to entry in your webpack config. It should end up in the same stylesheet bundle as your files (unless you do bundle splitting).

@danny-andrews
Copy link
Collaborator Author

@slavab89 Oh, it should be import 'flexboxgrid/lib/flexboxgrid.css';. It's stored in lib, not dist.

@danny-andrews danny-andrews deleted the transform-css-module-imports-during-build branch August 10, 2017 16:46
@danny-andrews
Copy link
Collaborator Author

@roylee0704 I'm sorry, I should have been more clear. This was a breaking change and should have resulted in a major version bump. I added a note to the old PR but failed to copy it over here.

@danny-andrews
Copy link
Collaborator Author

Got a fix up here.

@slavab89
Copy link

slavab89 commented Aug 11, 2017

@danny-andrews I think i should be using the dist folder - same as here. Also, i dont see a lib folder in flexboxgrid (it throws an error if i try to put lib).

Also, i'm not sure why but the classNames file that webpack generates has classes such as flexboxgrid__row___1y_mg flexboxgrid__col___3RqPP while flexboxgrid/dist/flexboxgrid.css has classes like _29XjX9PJIUZbQiXFTaW15q jT1yTaKoJWIC8KeS-FuVo.
I see this behaviour only when i add import 'flexboxgrid/dist/flexboxgrid.css'. If i dont add it then the flexboxgrid.css is not loaded at all.
Its like its running webpack twice but with different options.

@danny-andrews
Copy link
Collaborator Author

Sorry, I misread that. You want to do: import 'react-flexbox-grid/lib/index.css';. You want to import the build css from react-flexbox-grid, not flexboxgrid. Also, fyi, I have a fix for this up here which restores backwards compatibility by making this feature opt-in.

@slavab89
Copy link

Thanks. I've added import 'react-flexbox-grid/lib/index.css'; and it required me to do 2 changes:

  1. In case i didnt have a processing of react-flexbox-grid css files i would need to add it (i didnt so i had to add it)
  2. I couldnt use modules because it would create a mapping for the flexboxgrid__row___1y_mg flexboxgrid__col___3RqPP classes to other hash names.

@danny-andrews
Copy link
Collaborator Author

@slavab89 Yeah, it certainly isn't ideal. I have a fix up here. Mind taking a look @roylee0704?

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

Successfully merging this pull request may close these issues.

4 participants