| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- /**
- * Available build configurations: 4 in case of modules connecting to API, otherwise only 2
- * - development - offline
- * - development - online
- * - production - offline
- * - production - online
- *
- * Distinction between development and production targets by environment variable process.env.NODE_ENV
- * Online / offline versions (API usage or locally defined data) by command line arguments (default: online)
- */
- import path from 'path';
- import config from './config';
- import gulp from 'gulp';
- import { clean } from './tasks/clean';
- import { html } from './tasks/html';
- import { sprites } from './tasks/sprites';
- import { copyFonts, copyImages } from './tasks/copy';
- import { lint, lintJs, lintSass, lintHtml } from './tasks/lint';
- import { styles } from './tasks/styles';
- import { scripts } from './tasks/scripts';
- import { reload, serve } from './tasks/server';
- // Delete previously built files, generate html and sprites
- const prepare = gulp.series(
- clean,
- html,
- sprites
- );
- // Copy assets
- const finish = gulp.parallel(
- copyFonts,
- copyImages
- );
- // Execute complete build process
- const build = gulp.series(
- prepare,
- gulp.parallel(lintSass, lintJs, lintHtml),
- gulp.parallel(styles, scripts),
- finish
- );
- // Watch files and react accordingly
- const watchFiles = () => {
- // HTML
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.html,
- '*.html'
- ),
- gulp.series(html, reload)
- );
- // Javascript
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.js,
- '/**/*.(js|jsx|json)'
- ),
- gulp.series(scripts, reload)
- );
- // Sass
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.sass,
- '/**/*.scss'
- ),
- gulp.series(styles, reload)
- );
- // Fonts
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.fonts,
- '*.(woff|woff2)'
- ),
- gulp.series(copyFonts, reload)
- );
- // Images
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.images,
- '*.(png|jpg)'
- ),
- gulp.series(copyImages, reload)
- );
- // Sprites
- gulp.watch(
- path.join(
- config.paths.src,
- config.paths.images,
- config.paths.sprites,
- '*.svg'
- ),
- gulp.series(sprites, copyImages, reload)
- );
- };
- // Build first, then serve and watch files
- const watch = gulp.series(
- build,
- serve,
- watchFiles
- );
- // hack-a-di-hack: export named default task as default
- // (which is a javascript keyword but at the same time the name
- // of the gulp default task. Very good, gulp. Or, maybe, rather not
- export {
- watch as default,
- build,
- lint,
- prepare,
- watch
- };
|