Last active
November 28, 2016 09:39
-
-
Save JulienPradet/d37479e0b1f6b83bfa815b000574e648 to your computer and use it in GitHub Desktop.
Build a webpack bundle from a stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webpack from 'webpack' | |
import {Readable} from 'stream' | |
const entryStream = new Readable() | |
entryStream.push(` | |
import { configure } from '@kadira/storybook'; | |
function loadStories() { | |
require('./story1.js'); | |
require('./story2.js'); | |
require('./story3.js'); | |
} | |
configure(loadStories, module); | |
`) | |
entryStream.push(null) | |
var compiler = webpack(/* config */) | |
const bundleStream = compiler.transformStream(entryStream) | |
fs.writeFile('config.js', bundleStream) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For instance in react-storybook, the config.js file must require one by one each story.
In order to avoid doing so manually i'm preparing a tool that generates it according to conventions.
I could still save the generated
config.js
file and use the saved file as the entry. However it does not really feel node-y.I was wondering if it was possible to do somehting like this with webpack. I haven't found anything about it yet.
I hope it's a bit clearer if I put it this way :)