Skip to content

Commit e47597a

Browse files
author
Chris Thomas
committed
Allow using Storybook for local development.
Storybook is an easy to use UI to enable testing out features. This allows storybook to pick up changes from react-vis/src so that it can be used while developing components.
1 parent cce5980 commit e47597a

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

packages/website/.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-env node */
2+
const {join} = require('path');
3+
const isProd = process.env.NODE_ENV === 'production';
4+
5+
// This custom webpack config allows storybook to use the source files from 'react-vis'.
6+
// Changes can be made and instantly be reflected in storybook to allow quick development
7+
module.exports = {
8+
webpackFinal: config => {
9+
if (isProd) { return config;}
10+
11+
const reactVisPath = join(__dirname, '../../react-vis/src')
12+
13+
// Add an alias to 'react-vis' so that it looks in its src directory.
14+
config.resolve.alias['react-vis'] =reactVisPath
15+
config.resolve.modules.push(reactVisPath)
16+
17+
const jsRule = config.module.rules.find(rule => rule.test.test('test.js'));
18+
// Add the react-vis/src folder to the list of files to compile
19+
jsRule.include.push(reactVisPath)
20+
21+
const babelLoader = jsRule.use.find(x => x.loader === 'babel-loader');
22+
if (babelLoader) {
23+
babelLoader.options.rootMode = 'upward'
24+
}
25+
26+
return config;
27+
}
28+
}

packages/website/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = {
1616
},
1717
resolve: {
1818
alias: {
19-
react: resolve(__dirname, './node_modules/react')
19+
react: resolve(__dirname, './node_modules/react'),
20+
'react-vis': resolve('../react-vis/src')
2021
}
2122
}
2223
};

0 commit comments

Comments
 (0)