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

Added support for the haul react-native packager #1294

Merged
merged 5 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/react-native/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ For RN apps:

Once your app is started, changing the selected story in web browser will update the story displayed within your mobile app.

## Using Haul-cli

[Haul](https://github.com/callstack-io/haul) is an alternative to the react-native packager and has several advantages in that it allows you to define your own loaders, and handles symlinks better.

If you want to use haul instead of the react-native packager, modify the storybook npm script to:

```sh
storybook start -p 7007 --haul webpack.haul.storybook.js
```

Where webpack.haul.storybook.js should look something like this:

```js
module.exports = ({ platform }) => ({
entry: `./storybook/index.${platform}.js`,
// any other haul config here.
});
```

## Learn More

Check the `docs` directory in this repo for more advanced setup guides and other info.
7 changes: 6 additions & 1 deletion app/react-native/src/bin/storybook-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Server from '../server';
program
.option('-h, --host <host>', 'host to listen on')
.option('-p, --port <port>', 'port to listen on')
.option('--haul <configFile>', 'use haul with config file')
.option('-s, --secured', 'whether server is running on https')
.option('-c, --config-dir [dir-name]', 'storybook config directory')
.option('-e, --environment [environment]', 'DEVELOPMENT/PRODUCTION environment for webpack')
Expand Down Expand Up @@ -42,10 +43,14 @@ server.listen(...listenAddr, err => {
if (!program.skipPackager) {
const projectRoots = configDir === projectDir ? [configDir] : [configDir, projectDir];

let cliCommand = 'node node_modules/react-native/local-cli/cli.js start';
if (program.haul) {
cliCommand = `node node_modules/.bin/haul start --config ${program.haul} --platform all`;
}
// RN packager
shelljs.exec(
[
'node node_modules/react-native/local-cli/cli.js start',
cliCommand,
`--projectRoots ${projectRoots.join(',')}`,
`--root ${projectDir}`,
program.resetCache && '--reset-cache',
Expand Down