Skip to content

Instantly share code, notes, and snippets.

@elzup
Last active November 29, 2018 09:00
Show Gist options
  • Select an option

  • Save elzup/fcf8c7059a50727bbb19b6dba8a497c3 to your computer and use it in GitHub Desktop.

Select an option

Save elzup/fcf8c7059a50727bbb19b6dba8a497c3 to your computer and use it in GitHub Desktop.
s2s.config-redux.js
// @flow
import path from 'path'
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: ['s2s-action-types', { removePrefix: 'src/containers' }],
},
{
test: /actionTypes.js$/,
output: 'actions.js',
plugin: ['s2s-action-creater'],
},
{
test: /actionTypes.js$/,
input: 'reducer.js',
output: 'reducer.js',
plugin: ['s2s-reducer-case-creater'],
},
{
test: /actionTypes.js$/,
input: rootActionPath,
output: rootActionPath,
plugin: [
's2s-action-root',
{ input: 'src/**/actionTypes.js', output: rootActionPath },
],
},
// {
// test: /containers\/.+reducer.js/,
// plugin: ['s2s-initial-state-creater'],
// },
{
test: /containers\/.+reducer.js/,
input: 'reducer.test.js',
output: 'reducer.test.js',
plugin: ['s2s-reducer-test-case'],
},
{
test: /containers\/.+reducer.js/,
input: rootStatePath,
output: rootStatePath,
plugin: [
's2s-state-root',
{ input: 'src/containers/**/reducer.js', output: rootStatePath },
],
},
{
test: /containers\/.+reducer.js/,
input: rootReducerPath,
output: rootReducerPath,
plugin: [
's2s-reducer-root',
{ input: 'src/containers/**/reducer.js', output: rootReducerPath },
],
},
]
module.exports = plugins
exports.plugins = plugins
// @flow
const plugins = require('./s2s.config-redux')
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' },
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment