Closed alex88 closed 7 years ago
Hi alex88, did you manage to get this to work?
Hi @hirviid, unfortunately nope, I haven't :(
same issue. I'm specifically trying to get the javascript to load. have you had any luck here?
For anyone that comes back to this later, I've got it working by:
Full webpack.config.js (Mostly just the CSS loaders from React Redux Starter Kit):
const path = require('path');
const BASE_CSS_LOADER = 'css?sourceMap&-minimize';
module.exports = {
module: {
entry: {
app: ['bootstrap-loader']
},
loaders: [
{
test: /\.scss$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss',
'sass?sourceMap'
]
},
{
test: /\.css?$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss'
],
include: path.resolve(__dirname, '../')
}
]
}
}
And then in storybook/config.js:
import 'bootstrap-loader';
Hi all, thanks for the solution. Unfortunately it fails for me. I'm getting webpack errors for file extention such as "ttf", "svg", "woff"... I tried to add the following loader to my webpack config file:
loaders: [
... other loaders
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
loader: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
}
but after this none of my stories loads. Any idea?
Thanks
I manage to isolate the issue but I have no idea why this is not working. My config files is the following:
import { configure } from '@kadira/storybook';
import { setStubbingMode } from 'react-komposer';
import 'bootstrap-loader';
// Enable react-komposer stubbing.
// See: https://github.com/kadirahq/react-komposer#stubbing
setStubbingMode(true);
function loadStories() {
require('../client/modules/core/components/.stories');
require('../client/modules/noises/components/.stories');
require('../client/modules/users/components/.stories');
// require as many as stories you need.
}
configure(loadStories, module);
my webpack.config.js is like:
const path = require('path');
const BASE_CSS_LOADER = 'css?sourceMap&-minimize';
module.exports = {
module: {
entry: {
app: ['bootstrap-loader']
},
loaders: [
{
test: /\.scss$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss',
'sass?sourceMap'
]
},
{
test: /\.css?$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss'
],
include: path.resolve(__dirname, '../')
},
{
test : /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loader : 'file-loader'
}
]
}
}
when I start sorybook I do not see any story loaded on the storybook. But If I remove the import 'bootstrap-loader' from the config they show up. It is like the import is preventing the stories to be loaded...
After Investigating a bit I saw that when using import bootstrap-loader it also requires JQuery. I'm getting the following error. Uncaught ReferenceError: jQuery is not defined
I'm now looking for a solution for this.
Had the same issue but adding the following loader solved the issue with jQuery for me:
{
test: /bootstrap-sass(\\|\/)assets(\\|\/)javascripts(\\|\/)/,
loader: 'imports?jQuery=jquery'
}
You also need to install the imports-loader
package.
Hey gkaran, thanks for the solution. It did the trick for me. :)
I'm try to add bootstrap-loader
into storybook (React 16, webpack 3.4.1, storybook 3.1.9).
I have 'compile' solutions above, but I get errors for files with name glyphicons-halflings-regular
but different extensions eot, woff2, woff, ttf, svg
:
You may need an appropriate loader to handle this file type.
my config
import { configure } from '@storybook/react';
import 'bootstrap-loader';
function loadStories() {
require('../stories');
}
configure(loadStories, module);
webpack
const path = require('path');
const BASE_CSS_LOADER = 'css?sourceMap&-minimize';
module.exports = {
module: {
entry: {
app: ['bootstrap-loader']
},
loaders: [
{
test: /\.scss$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss',
'sass?sourceMap'
]
},
{
test: /\.css?$/,
loaders: [
'style',
BASE_CSS_LOADER,
'postcss'
],
include: path.resolve(__dirname, '../')
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loader: 'file-loader'
},
{
test: /bootstrap-sass(\\|\/)assets(\\|\/)javascripts(\\|\/)/,
loader: 'imports?jQuery=jquery'
}
]
}
};
so what I could miss/mistake?
You're using loaders
, change this to rules
@ndelangen , this way?
rules: [
{
test: /\.scss$/,
rules: [
'style',
BASE_CSS_LOADER,
'postcss',
'sass?sourceMap'
]
},
...
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
rules: 'file-loader'
},
{
test: /bootstrap-sass(\\|\/)assets(\\|\/)javascripts(\\|\/)/,
rules: 'imports?jQuery=jquery'
}
]
Check out the webpack 1 to webpack 2 migration. https://webpack.js.org/guides/migrating/
the queries (?
) and options (!
) should be split out,
the property you set on a rule-object is use
:
https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules
Basicly, you webpack config is a webpack 1. Which storybook does not support anymore.
Could somebody help with properly webpack.config.js for Webpack 3?
I think such a question would be best asked on https://stackoverflow.com where there are more users with webpack knowledge.
Crikey!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-rc.0 containing PR #21491 that references this issue. Upgrade today to the @next
NPM tag to try it out!
npx sb@next upgrade --prerelease
Hi there,
in my project I'm using
bootstrap--loader
within the entry configuration, in storybook I have:and