This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
forked from nteract/nteract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styleguide.config.js
102 lines (98 loc) · 2.74 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
// @format
const path = require("path");
const reactDocgenTypescript = require("react-docgen-typescript").withCustomConfig(
"./tsconfig.base.json"
);
const typescriptPropsParser = reactDocgenTypescript.parse;
module.exports = {
title: "nteract components",
defaultExample: false,
propsParser: typescriptPropsParser,
resolver: require("react-docgen").resolver.findAllComponentDefinitions,
getComponentPathLine: (componentPath) => {
const toPascalCase = (string) =>
string
.match(/[a-z]+/gi)
.map(
(word) => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()
)
.join("");
const name = path.basename(componentPath, ".tsx");
const from = componentPath
.replace(/^packages\//, "@nteract/")
.replace(/\.tsx?$/, "");
return `import ${toPascalCase(name)} from '${from}';`;
},
sections: [
{
name: "Introduction",
content: "styleguide-components/intro.md",
},
{
name: "@nteract/presentational-components",
components: "packages/presentational-components/src/components/*.tsx",
},
// {
// name: "@mybinder/host-cache",
// components: "packages/host-cache/src/components/*.tsx"
// },s
],
// For overriding the components styleguidist uses
styleguideComponents: {
LogoRenderer: path.join(__dirname, "styleguide-components", "logo.tsx"),
},
compilerConfig: {
// Allow us to use {...props}
objectAssign: "Object.assign",
transforms: {
// whether template strings get transpiled (we don't want it to, so that we can use the native functionality)
templateString: false,
},
},
template: {
body: {
raw: `
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129108362-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-129108362-2');
</script>`,
},
},
webpackConfig: {
node: {
fs: "empty",
child_process: "empty",
net: "empty",
canvas: "empty",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
},
externals: ["canvas"],
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
compilerOptions: {
strict: true,
jsx: "react",
composite: true,
},
projectReferences: true,
transpileOnly: true,
},
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
},
};