-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayroom.config.js
84 lines (78 loc) · 2.28 KB
/
playroom.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
const ReactIs = require("react-is");
const { default: parsePropTypes } = require("parse-prop-types");
const PacktrackerPlugin = require("@packtracker/webpack-plugin");
module.exports = {
title: "Material-UI",
outputPath: "./dist/playroom",
components: "./playroom/components.js",
themes: "./playroom/themes.js",
frameComponent: "./playroom/FrameComponent.js",
widths: [320, 375, 768, 1024],
getStaticTypes(playroomConfig) {
const components = require(playroomConfig.components);
return Object.fromEntries(
Object.entries(components).map(([name, maybeElementType]) => {
let props = maybeElementType;
const isWithStylesDecorated =
ReactIs.isValidElementType(maybeElementType) &&
maybeElementType.Naked;
if (isWithStylesDecorated) {
props = parsePropTypes(maybeElementType.Naked);
}
return [name, props];
})
);
},
webpackConfig: playroomConfig => {
const plugins = [];
if (process.env.PT_PROJECT_TOKEN) {
plugins.push(
new PacktrackerPlugin({
upload: true,
fail_build: true,
// provided by netlify
project_token: process.env.PT_PROJECT_TOKEN,
branch: process.env.BRANCH
})
);
}
return {
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: require.resolve("babel-loader"),
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
// need this for hot reloading the demo source
plugins: ["@babel/plugin-proposal-class-properties"]
}
}
}
]
},
node: {
fs: "empty"
},
plugins,
resolve: {
alias: {
react: require.resolve("react"),
"react-dom": require.resolve("react-dom")
}
}
};
},
exampleCode: `
<DemoPrimarySearchAppBar />
<Typography variant="h4">Material-UI Playroom</Typography>
<List>
<ListItem>components are not prefixed</ListItem>
<ListItem>Demos (composite components) are prefixed with 'Demo'</ListItem>
<ListItem>Some icons are included and prefixed with 'Icon'</ListItem>
</List>
<DemoBottomAppBar />
`
};