-
Notifications
You must be signed in to change notification settings - Fork 1
/
s2s.config.js
97 lines (91 loc) · 2.85 KB
/
s2s.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
// @flow
const path = require('path')
const actionTypesPlugin = require('babel-plugin-s2s-action-types').default
const actionCreaterPlugin = require('babel-plugin-s2s-action-creater').default
const reducerCaseCreaterPlugin = require('babel-plugin-s2s-reducer-case-creater')
.default
const actionRootPlugin = require('babel-plugin-s2s-action-root').default
const reducerTestCasePlugin = require('babel-plugin-s2s-reducer-test-case')
.default
// const initilaStetePlugin = require('babel-plugin-s2s-initial-state-creater').default
const stateRootPlugin = require('babel-plugin-s2s-state-root').default
const reducerRootPlugin = require('babel-plugin-s2s-reducer-root').default
const cwd = process.cwd()
const getRootDir = (...x) => path.resolve(cwd, 'src', ...x)
const getTyepDir = x => getRootDir('types', x)
const rootReducerPath = getRootDir('reducer.js')
const rootActionPath = getTyepDir('action.js')
const rootStatePath = getTyepDir('state.js')
const plugins = [
{
test: /actionTypes.js$/,
plugin: [actionTypesPlugin, { removePrefix: 'src/containers' }],
},
{
test: /actionTypes.js$/,
output: 'actions.js',
plugin: [actionCreaterPlugin],
},
{
test: /actionTypes.js$/,
input: 'reducer.js',
output: 'reducer.js',
plugin: [reducerCaseCreaterPlugin],
},
{
test: /actionTypes.js$/,
input: rootActionPath,
output: rootActionPath,
plugin: [
actionRootPlugin,
{ input: 'src/**/actionTypes.js', output: rootActionPath },
],
},
// {
// test: /containers\/.+^(?!Container)\/reducer.js/,
// plugin: [initilaStetePlugin],
// },
{
test: /containers\/.+reducer.js/,
input: 'reducer.test.js',
output: 'reducer.test.js',
plugin: [reducerTestCasePlugin],
},
{
test: /containers\/.+reducer.js/,
input: rootStatePath,
output: rootStatePath,
plugin: [
stateRootPlugin,
{ input: 'src/containers/**/reducer.js', output: rootStatePath },
],
},
{
test: /containers\/.+reducer.js/,
input: rootReducerPath,
output: rootReducerPath,
plugin: [
reducerRootPlugin,
{
input: 'src/containers/**/reducer.js',
output: rootReducerPath,
combineReducers: './config',
},
],
},
]
module.exports = {
watch: './**/*.js',
plugins,
templates: [
{ test: /containers\/.*\/index.js/, input: 'containers.js' },
{ test: /components\/.*\/index.js/, input: 'components.js' },
{ test: /components\/.*\/index.test.js/, input: 'component.test.js' },
{ test: /reducer.js/, input: 'reducer.js' },
{ test: /reducer.js/, input: 'reducer.test.js', output: 'reducer.test.js' },
{ test: /reducer.js/, input: 'actionTypes.js', output: 'actionTypes.js' },
{ test: /selectors.js/, input: 'selectors.js' },
{ test: /selectors.test.js/, input: 'selectors.test.js' },
{ test: /logic.js/, input: 'logic.js' },
],
}