forked from hallister/semantic-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyleguide.config.js
61 lines (53 loc) · 2.26 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
/* eslint-disable */
var path = require('path');
var glob = require('glob');
module.exports = {
title: 'Semantic UI Components for React',
components: function () {
return glob.sync(path.resolve(__dirname, 'src/components/**/*.jsx')).filter(function (module) {
// exclude tests files
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('src/loaders');
// webpackConfig.resolve.alias['rsg-components/TableOfContents'] = path.join(__dirname, 'src/styleguide/TableOfContents');
webpackConfig.resolve.alias['rsg-components/StyleGuide'] = path.join(__dirname, 'src/styleguide/StyleGuide');
return webpackConfig;
}
};
/* eslint-enable */