-
Notifications
You must be signed in to change notification settings - Fork 19
/
styleguide.config.js
138 lines (137 loc) · 3.51 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
129
130
131
132
133
134
135
136
137
138
const path = require('path')
const pkg = require('./package.json')
module.exports = {
title: 'React-BMapGL文档',
sections: [
{
name: '快速入门',
content: 'README.md',
},
{
name: '常见问题',
content: 'FAQ.md',
},
{
name: '反馈BUG',
href: 'https://github.com/huiyan-fe/react-bmapgl/issues',
external: true,
shouldOpenInNewTab: true,
},
{
name: '基础类',
components: ['src/Map/Map.tsx', 'src/Map/MapApiLoaderHOC.tsx'],
sectionDepth: 1,
},
{
name: '地图控件',
components: 'src/Control/[A-Z]*.tsx',
sectionDepth: 1,
},
{
name: '覆盖物',
components: 'src/Overlay/[A-Z]*.tsx',
sectionDepth: 1,
},
{
name: '地图图层',
components: 'src/Layer/[A-Z]*.tsx',
sectionDepth: 1,
},
{
name: '开源工具库',
components: 'src/Library/[A-Z]*.tsx',
sectionDepth: 1,
},
{
name: '地图服务',
components: 'src/Services/[A-Z]*.tsx',
sectionDepth: 1,
},
{
name: '自定义组件',
components: 'src/Custom/[A-Z]*.tsx',
sectionDepth: 1,
},
],
pagePerSection: true,
ribbon: {
url: 'https://github.com/huiyan-fe/react-bmapgl',
text: 'Star me on GitHub',
},
// 配置导出路径
getComponentPathLine(cppath) {
const name = path.basename(cppath, '.tsx')
return `import {${name}} from '${pkg.name}'`
},
// 配置对应的example 文档
getExampleFilename(cppath) {
const baseDir = path.resolve('website')
const srcDir = path.resolve('src')
const relative = path.relative(srcDir, cppath)
return path.join(baseDir, relative).replace(/\.tsx?$/, '.md')
},
template: {
head: {
links: [
{
rel: 'SHORTCUT ICON',
href: './logo.ico'
}
],
scripts: [
{
type: 'text/javascript',
src: '//api.map.baidu.com/api?type=webgl&v=1.0&ak=1XjLLEhZhQNUzd93EjU5nOGQ'
}
]
},
},
previewDelay: 1000,
skipComponentsWithoutExample: true,
theme: './rsg-config/theme.config.js',
styles: './rsg-config/style.config.js',
exampleMode: 'expand',
usageMode: 'expand',
styleguideComponents: {
LogoRenderer: path.join(__dirname, 'rsg-config/Logo'),
LinkRenderer: path.join(__dirname, 'rsg-config/Link'),
RibbonRenderer: path.join(__dirname, 'rsg-config/Ribbon'),
},
// Typescript支持
resolver: require('react-docgen').resolver.findAllComponentDefinitions,
propsParser: require('react-docgen-typescript').withCustomConfig('./tsconfig.json', {
// If set to true, types that are optional will not display " | undefined" in the type.
shouldRemoveUndefinedFromOptional: true
}).parse,
webpackConfig: {
resolve: {
extensions: ['.ts', '.tsx', '.js', 'jsx', 'json'],
alias: {
'react-bmapgl': path.resolve('src')
}
},
module: {
rules: [
{
test: /\.(js||jsx|ts|tsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(png|jpg|jpeg|gif|webp|ico)$/,
loader: require.resolve('file-loader'),
options: {
name: '[name].[ext]'
}
},
],
},
},
dangerouslyUpdateWebpackConfig(webpackConfig, env) {
if (env === 'production') {
// 修改图片等静态资源文件
webpackConfig.output.publicPath = '//mapopen.cdn.bcebos.com/github/react-bmapgl/'
}
return webpackConfig
}
}