-
Notifications
You must be signed in to change notification settings - Fork 3
Variables from the config and from bulma are not available in the css modules #1
Comments
Hey, sure! Could you share your webpack config here? |
Hey, thanks for the feedback! I actually can setup bulma variables through
|
Ah ok I see what you mean. TL;DR you'll have to import your Basically, what bulma-loader does behind the scenes is this: The reason why it's done like that today is to avoid causing conflicts or breaking your sass. Until bulma-loader gives you an easy way of doing this, you'll have to import the config file manually in your own code. Lets pretend you're doing something like this in your code, in a file located here: .login-button {
composes: button primary from 'bulma';
.icon {
background-color: $primary-invert;
color: $primary;
}
} Change it to the following to make it work: @import "config";
.login-button {
composes: button primary from 'bulma';
.icon {
background-color: $primary-invert;
color: $primary;
}
} Let me know if that works out for you! 😄 |
Ok, got that. Thank you. That is exactly what I was thinking about. I see the great potential in bulma and I like the principles how it is built much more than any other solutions. Wanted also to ask you few questions about practices using such approach that is described in the instructions:
Hero titleHero subtitle
|
@stipsan And how do you access breakpoints from bulma? |
No worries, I agree the outlook of Bulma is looking really good. The only cases I'm not using it is where I have to support browsers that don't support flexbox layouts. Nested structuresYou don't need to worry about it, check out the example here, that's nested: https://github.com/stipsan/bulma-loader#importing-customized-bulma-css // in webpack.config.js
{
test: /\bulma.sass$/,
loaders: ['classnames', ExtractTextPlugin.extract('style', 'sass')])
}
// react component
import bulma from 'bulma/sass/bulma.sass'
export const Welcome = () => <div className={bulma('hero')}>
<div className={bulma('hero-content')}>
<h1 className={bulma('title')}>Welcome!</h1>
<h2 className={bulma('subtitle')}>Long time no see :-)</h2>
</div>
</div> That's on top of my head, so you may need to tweak it for it to work. Combining SASS and CSS modulesYes there is, and yeah there's very little information on it. I had to dig deep to figure out how it works. Given this example: .tabs {
composes: tabs from 'bulma';
} this is what is called an external reference in the CSS modules spec. webpack will resolve it using the path lookup it uses in general. In this particular case it will resolve loaders: ["style", "css?modules&importLoaders=1", "sass"] That last statement in the loaders array, For instance, this would fail: loaders: ["style", "css?modules&importLoaders=1", "autoprefixer", "sass"] Because only 1 loader is imported, and in this case it's You can find more information about it here and here. Accessing breakpointsI know about two ways you can do that:
Hope that helps 😄 |
@stipsan Great explanation! Really appreciate! |
@r0st1kuzh you're welcome! |
@stipsan and what is the right webpack config to make icon fonts from bulma to work in context of css modules? |
bulma is just using fontawesome. If you install this: https://www.npmjs.com/package/font-awesome Assuming you got this setup to load the font files: {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
} You should be able to do this: .icon {
composes: icon from 'bulma';
}
.fa-github {
composes: fa fa-github from 'font-awesome';
} Using this in your react render: <span className={cx('icon')}>
<i className={cx('fa-home')} />
</span> |
Thanks a lot! That works! |
Awesome! |
Can you help me to figure out how to make it work?
The text was updated successfully, but these errors were encountered: