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

Importing CSS only in Storybook #156

Closed
mgarf opened this issue May 2, 2016 · 7 comments
Closed

Importing CSS only in Storybook #156

mgarf opened this issue May 2, 2016 · 7 comments

Comments

@mgarf
Copy link

mgarf commented May 2, 2016

This is an unusual use case but I'm trying to import the css only for use in the storybook. Currently this is what I have:

Config.js

import { configure } from '@kadira/storybook';
require('../node_modules/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.css');

function loadStories() {
  require('../components/stories/StandardInput');
  // require as many stories as you need.
}

configure(loadStories, module);

webpack.config.js

const path = require('path');
module.exports = {
  module: {
    loaders: [
      {
        test: /\.css?$/,
        loaders: [ 'style', 'raw', 'css'],
        include: path.resolve(__dirname, '/')
      }
    ]
  }
}

I'm getting the following error:

ERROR in Loader C:\Users******\Desktop\JSApp\node_modules\raw\raw.js didn't return a function
@ ./~/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.css 4:14-119 13:2-17:4 14:20-125

@arunoda
Copy link
Member

arunoda commented May 2, 2016

May be remove the css loader. That may help.

@arunoda
Copy link
Member

arunoda commented May 2, 2016

Also, you should try to do following changes.

  • include should be this: include: path.resolve(__dirname, '../')
  • CSS import should be like as follow:
import '@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.css'

@mgarf
Copy link
Author

mgarf commented May 2, 2016

thank you for your quick response.

I made the changes you suggested but still getting the following:

ERROR in Loader C:\Users\michael.garfinkel\Desktop\JSApp\node_modules\raw\raw.js didn't return a function
 @ ./~/@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.css 4:14-92 13:2-17:4 14:20-98

Updated Bits:

webpack.config.js

const path = require('path');
module.exports = {
  module: {
    loaders: [
      {
        test: /\.css?$/,
        loaders: [ 'style', 'raw'],
        include: path.resolve(__dirname, '../')
      }
    ]
  }
}

config.js

import { configure } from '@kadira/storybook';
import '@salesforce-ux/design-system/assets/styles/salesforce-lightning-design-system.css';

function loadStories() {
    require('../components/stories/StandardInput');
    require('../components/stories/BillingStatementRow');
  // require as many stories as you need.
}

configure(loadStories, module);

@arunoda
Copy link
Member

arunoda commented May 2, 2016

May be seems like an issue in the raw module. Make sure you've installed raw npm module into your app. (It's version should be something like: 0.5.1)

@arunoda
Copy link
Member

arunoda commented May 2, 2016

This is a similar project you can use as a reference: https://github.com/kadira-samples/react-storybook-demo/tree/master/.storybook

@mgarf
Copy link
Author

mgarf commented May 2, 2016

Yeah,

I just looked into my package json and raw was missing. I think i had raw in but not raw-loader. Once i did that it all worked. Thank you for your help!

@mgarf mgarf closed this as completed May 2, 2016
@arunoda
Copy link
Member

arunoda commented May 2, 2016

Great.

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

No branches or pull requests

2 participants