forked from ReactTraining/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.mjs
52 lines (48 loc) · 1.22 KB
/
plopfile.mjs
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
import fs from 'fs'
import path from 'path'
const appPath = `apps/spa`
export default function create(plop) {
// controller generator
plop.setGenerator('Component', {
prompts: [
{
type: 'input',
name: 'name',
message: 'Component Name',
},
{
type: 'confirm',
name: 'styles',
message: 'Add SCSS Module?',
},
],
actions: (input) => {
const actions = [
{
type: 'add',
path: path.join(appPath, '{{name}}/index.ts'),
templateFile: 'utils/plop-component/index.hbs',
},
]
if (input.styles) {
actions.push({
type: 'add',
path: path.join(appPath, '{{name}}/{{name}}.module.scss'),
templateFile: 'utils/plop-component/scss.hbs',
})
actions.push({
type: 'add',
path: path.join(appPath, '{{name}}/{{name}}.tsx'),
templateFile: 'utils/plop-component/component-with-scss.hbs',
})
} else {
actions.push({
type: 'add',
path: path.join(appPath, '{{name}}/{{name}}.tsx'),
templateFile: 'utils/plop-component/component.hbs',
})
}
return actions
},
})
}