Skip to content

Commit

Permalink
New gulp build
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 17, 2019
1 parent 1daf56c commit 5191b32
Show file tree
Hide file tree
Showing 6 changed files with 2,837 additions and 2,097 deletions.
2 changes: 1 addition & 1 deletion bin/test_openapi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
'use strict'

const { runCli } = require('../src')
const { runCli } = require('../dist')

runCli()
5 changes: 2 additions & 3 deletions gulp/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"test",
"*.md"
],
"BUILD": ["{index,register,gulpfile.babel,.babelrc}.js", "src"],
"BUILD_SRC": ["src"],
"BUILD_DIST": ["dist"],
"BUILD": "src",
"BUILD_DIST": "dist",
"DEV": [
"{index,register,gulpfile.babel,.babelrc}.js",
"src",
Expand Down
44 changes: 38 additions & 6 deletions gulp/tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
'use strict'

const { series } = require('gulp')
const { src, dest, series, parallel } = require('gulp')
const { include } = require('gulp-ignore')
const del = require('del')
const yamlToJson = require('gulp-yaml')

const { BUILD, BUILD_DIST } = require('../files')
const { getWatchTask } = require('../utils')
const { BUILD_SRC, BUILD_DIST } = require('../files')
const gulpExeca = require('../exec')

const clean = () => del(BUILD_DIST)

// eslint-disable-next-line fp/no-mutation
clean.description = 'Remove build directory'

const copy = () =>
src([`${BUILD}/**`, `!${BUILD}/**/*.{y{,a}ml,js,ts,jsx,tsx}`], {
dot: true,
}).pipe(dest(BUILD_DIST))

// eslint-disable-next-line fp/no-mutation
copy.description = 'Copy all sources files to build directories'

const babel = () =>
gulpExeca(
`babel ${BUILD_SRC} --out-dir ${BUILD_DIST} --copy-files --delete-dir-on-start --source-maps --no-comments --minified --retain-lines`,
`babel ${BUILD} --out-dir ${BUILD_DIST} --source-maps --no-comments --minified --retain-lines`,
)

const build = series(babel)
// eslint-disable-next-line fp/no-mutation
babel.description = 'Transpile JavaScript files with Babel'

const yaml = () =>
src(`${BUILD}/**`, { dot: true })
.pipe(include(/\.ya?ml$/u))
.pipe(yamlToJson({ schema: 'JSON_SCHEMA', space: 2 }))
.pipe(dest(BUILD_DIST))

// eslint-disable-next-line fp/no-mutation
yaml.description = 'Convert YAML files to JSON'

const build = series(clean, parallel(copy, babel, yaml))

// eslint-disable-next-line fp/no-mutation
build.description = 'Build source files'
build.description = 'Build the application'

const buildwatch = getWatchTask({ BUILD: build }, build)

// eslint-disable-next-line fp/no-mutation
buildwatch.description = 'Build source files in watch mode'
buildwatch.description = 'Build the application in watch mode'

module.exports = {
build,
buildwatch,
clean,
copy,
babel,
yaml,
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

module.exports = {
...require('./src'),
...require('./dist'),
// eslint-disable-next-line import/no-internal-modules
...require('./src/core/spec'),
...require('./dist/core/spec'),
}
Loading

0 comments on commit 5191b32

Please sign in to comment.