-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Meteor CSS not importing #96
Comments
You need to import CSS inside the story files. You can also done that with config.js as well. |
OK great, thanks... Will that work for '.less' files too? How about module loaded frameworks like bootstrap? |
For the less, you need to configure a less webpack loader. |
I came here for the same issue - trying to use SCSS with React Storybook. Is webpack the only solution? |
@ffxsam Yep. That's the only way which supports hot loading. |
Ok I finally got this working last night... thought I'd share. Webpack builder + bootstrap + font-awesome + meteor This isn't perfect, and I think I might be duplicating effort a bit, but it's at least working. // .storybook/webpack.config.js
const path = require('path');
module.exports = {
entry: [
'bootstrap-webpack!' + path.resolve(__dirname, './bootstrap.config.js'),
'font-awesome-webpack!' + path.resolve(__dirname, './font-awesome.config.js')
],
output: {
path: path.join(__dirname, '../public'),
filename: 'webpack-output.js'
},
//resolveLoader: { root: path.resolve(__dirname, '../node_modules') },
module: {
loaders: [
{
test: /\.css?$/,
loaders: [ 'style', 'raw' ],
include: path.resolve(__dirname, '../')
},
{ test: /bootstrap\/js\//, loader: 'imports?jQuery=jquery' },
{ test: /\.woff(2)?(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?limit=10000&mimetype=application/font-woff' },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?limit=10000&mimetype=application/octet-stream' },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?limit=10000&mimetype=image/svg+xml' }
]
}
};
// .storybook/config.js
import { configure } from '@kadira/storybook';
function loadStories() {
require('bootstrap-webpack');
require('font-awesome-webpack');
require('../imports/ui/layouts/stories/Header.jsx'); // <-- includes app css
...
}
// .storybook/font-awesome.config.js
module.exports = {
// Default for the style loading
styleLoader: 'style-loader!css-loader!less-loader',
styles: {
'mixins': true,
'bordered-pulled': true,
'core': true,
'fixed-width': true,
'icons': true,
'larger': true,
'list': true,
'path': true,
'rotated-flipped': true,
'animated': true,
'stacked': true
}
};
// .storybook/font-awesome.config.js
module.exports = {
scripts: {
// add every bootstrap script you need
'transition': true
},
styles: {
// add every bootstrap style you need
'mixins': true,
'normalize': true,
'print': true,
'scaffolding': true,
'type': true
}
}; |
Boggles my mind why people like webpack so much.. ugh. All that, just to get everything working? @arunoda I would recommend maybe adding a webpack config to the package so that Sass & LESS work out of the box, as I'm willing to bet there are lots of projects that don't use plain CSS. |
We can add a link to above when we are talking about CSS in Meteor. We won't bundle anything default related to CSS with Storybook. I hope that's the best way. |
Ok, but even if you can have webpack boilerplate that we can copy/paste that will make CSS, Sass, and LESS work.. that would be awesome. Because lots of Meteor folks like myself haven't had a need to use webpack thanks to Meteor's build system, and the learning curve for webpack is massive. I know I don't have the time to invest in learning it. |
@ffxsam Yes. We can simply put it there. |
Many thanks! 😀 |
@ffxsam BTW: Send me a PR, if you can do if before me. |
Love to, but I don't know webpack - sorry! |
@zeroasterisk Thank you! That solved my problem. |
We will use this or similar by default. We'll work on this with our new tool |
I'm following your docs/guide for CSS importing, from a Meteor app, and I am not getting the CSS into React Storybook, but it is in my Meteor app... and both are running at the same time.
React Storybook has no CSS files loading via Chrome Inspector Network.
The text was updated successfully, but these errors were encountered: