Skip to content

Commit

Permalink
Merge pull request #1294 from ericwooley/haul-support
Browse files Browse the repository at this point in the history
Added support for the `haul` react-native packager
  • Loading branch information
shilman authored Jun 16, 2017
2 parents 40858bf + 58a11ec commit f3b0636
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit f3b0636

Please sign in to comment.