-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathstyleguide.config.js
128 lines (120 loc) · 4.66 KB
/
styleguide.config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* eslint-disable */
var path = require('path');
var glob = require('glob');
module.exports = {
title: 'Semantic UI Components for React',
sections: [
{
name: 'Elements',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/elements/**/*.jsx')).filter(module => {
return !(/(__tests__|examples|simple\/)/.test(module));
});
}
},
{
name: 'Simple elements',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/elements/simple/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Collections - Form',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/collections/form/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Collections - Grid',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/collections/grid/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Collections - Table',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/collections/table/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Collections - Message',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/collections/message/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Collections - Breadcrumb',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/collections/breadcrumb/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Modules',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/modules/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
},
{
name: 'Views',
components: () => {
return glob.sync(path.resolve(__dirname, 'src/components/views/**/*.jsx')).filter(module => {
return !(/(__tests__|examples)/.test(module));
});
}
}
],
skipComponentsWithoutExample: true,
serverPort: 4000,
getExampleFilename: function (componentPath) {
var parsed = path.parse(componentPath);
var exampleDir = path.join(parsed.dir, 'examples');
return path.join(exampleDir, parsed.name + '.examples.md');
// return componentPath.replace(/\.jsx?$/, '.examples.md');
},
getComponentPathLine: function (componentPath) {
/** @var {string} */
var name = path.basename(componentPath, '.jsx');
// capitalize
name = name.charAt(0).toUpperCase() + name.slice(1);
return 'import { ' + name + ' } from \'semantic-react\';';
},
template: "./src/styleguide.template.html",
updateWebpackConfig: function(webpackConfig, env) {
var dir = path.join(__dirname, 'src', 'components');
var styleguideComponentsDir = path.join(__dirname, 'src', 'styleguide');
var babelConfig = {
test: /\.(jsx|js)$/,
loader: 'babel',
include: [
dir,
styleguideComponentsDir
],
exclude: /(__tests__|node_modules|examples)/,
};
if (process.env.NODE_ENV !== 'production') {
babelConfig.query = { presets: ['react-hmre'] };
}
webpackConfig.module.loaders.push(babelConfig);
webpackConfig.devtool = 'inline-source-map';
webpackConfig.resolve.extensions.push('.es6');
// Add enhanced props loader
webpackConfig.resolveLoader.modulesDirectories.unshift(path.join(__dirname, 'src', 'loaders'));
webpackConfig.resolve.alias['rsg-components/StyleGuide'] = path.join(__dirname, 'src/styleguide/StyleGuide');
return webpackConfig;
}
};
/* eslint-enable */