-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathmain.js
65 lines (58 loc) · 1.66 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path');
const webpack = require('webpack');
const ringConfig = require('../webpack.config').createConfig();
const pkgConfig = require('../package.json').config;
module.exports = {
stories: [
// Make welcome stories default
'../src/welcome.examples.js',
'../src/**/*.examples.{js,ts,tsx}'
],
presets: [require.resolve('./custom-header/header-preset')],
addons: [
'@storybook/addon-storysource',
'@storybook/addon-essentials',
'@storybook/addon-a11y'
],
core: {
builder: 'webpack5'
},
webpackFinal(config) {
ringConfig.componentsPath.push(
__dirname,
path.resolve(__dirname, '../src')
);
ringConfig.loaders.babelLoader.options.plugins = [[
'babel-plugin-react-docgen',
{
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
}
]];
config.module.rules = [
...ringConfig.config.module.rules,
config.module.rules.find(rule =>
rule.include instanceof RegExp &&
rule.include.test('node_modules/acorn-jsx')),
{
test: /\.md$/,
loader: 'raw-loader'
},
{
test: /\.examples\.js$/,
loader: require.resolve('@storybook/source-loader'),
enforce: 'pre'
},
{
test: /\.svg$/,
loader: require.resolve('svg-inline-loader'),
options: {removeSVGTagAttrs: false},
include: [/@primer\/octicons/, /@jetbrains\/logos/]
}
];
const serverUri = pkgConfig.hub;
const clientId = pkgConfig.clientId;
const hubConfig = JSON.stringify({serverUri, clientId});
config.plugins.push(new webpack.DefinePlugin({hubConfig}));
return config;
}
};