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

Flexboxgrid media rules doesn't import globally from react-starter-kit #1274

Closed
blitss opened this issue May 21, 2017 · 2 comments
Closed

Flexboxgrid media rules doesn't import globally from react-starter-kit #1274

blitss opened this issue May 21, 2017 · 2 comments

Comments

@blitss
Copy link

blitss commented May 21, 2017

I'm trying to import flexboxgrid css module from starter-kit.
I've added import rule to Layout.css:
@global-import 'flexboxgrid' ;
But media rules are using local names:
f4f7617e18e54b34879e7d44eefdf3b9
Here's an example: https://github.com/Blitss/react-starter-kit
What can I do to fix it? I'm using node v7.9.0 on Windows

@frenzzy
Copy link
Member

frenzzy commented May 21, 2017

You can specify two css loaders in your tools/webpack.config.js for local and global styles separately like so:

{
  test: /\.css$/,
  include: [path.resolve(__dirname, '../src')], // Internal Styles
  use: [
    { loader: 'isomorphic-style-loader' },
    { loader: 'css-loader', // CSS Modules Enabled
      options: {
        importLoaders: 1,
        sourceMap: isDebug,
        modules: true,
        localIdentName: isDebug ? '[name]-[local]-[hash:base64:5]' : '[hash:base64:5]',
        minimize: !isDebug,
        discardComments: { removeAll: true },
    } },
    { loader: 'postcss-loader', options: { config: './tools/postcss.config.js' } },
  ],
},
{
  test: /\.css$/,
  exclude: [path.resolve(__dirname, '../src')], // External Styles
  use: [
    { loader: 'isomorphic-style-loader' },
    { loader: 'css-loader', // CSS Modules Disabled
      options: {
        sourceMap: isDebug,
        minimize: !isDebug,
        discardComments: { removeAll: true },
      } },
  ],
},

Then import external css inside your component:

import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import external from 'external.css';
import s from './MyComponent.css';

class MyComponent extends React.Component {
  render() {
    return <div className={s.local}><div className="global">Hi</div></div>
  }
}

export default withStyles(external, s)(MyComponent);

This was referenced May 23, 2017
@langpavel
Copy link
Collaborator

Merge latest changes and import your file from JS, like normalize.css is now. Do not @import from css!

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

3 participants