function watchJekyll(neverDone) { return watch([ 'src/**/*.{csv,html,md,yml}' ], series(buildJekyll, function reloadBrowsers(done) { browserSync.reload() done() })) }
gulp.task('clean.once', (done: any) => { if (firstRun) { firstRun = false; gulp.series([ 'clean.dev' ])(done); } else { util.log('Skipping clean on rebuild'); done(); } });
function watch(){ return gulp.watch([ `${paths.src}/**/*`, `index.html`, `systemjs.config.js`, `styles.css`, `!${paths.src}/**/*.spec.ts` ], gulp.series('build:dev')); }
let refresh = debounce(() => { if (isBuilding) { log('Watcher: A build is already in progress, deferring change detection...'); return; } isBuilding = true; let paths = pendingRefreshPaths.splice(0); let refreshTasks = []; // determine which tasks need to be executed // based on the files that have changed for (let watcher of watches) { if (Array.isArray(watcher.source)) { for(let source of watcher.source) { if (paths.find(path => minimatch(path, source))) { refreshTasks.push(watcher); } } } else { if (paths.find(path => minimatch(path, watcher.source))) { refreshTasks.push(watcher); } } } if (refreshTasks.length === 0) { log('Watcher: No relevant changes found, skipping next build.'); isBuilding = false; return; } log(`Watcher: Running ${refreshTasks.map(x => x.name).join(', ')} tasks on next build...`); let toExecute = gulp.series( readProjectConfiguration, gulp.parallel(refreshTasks.map(x => x.callback)), writeBundles, (done) => { isBuilding = false; watchCallback(); done(); if (pendingRefreshPaths.length > 0) { log('Watcher: Found more pending changes after finishing build, triggering next one...'); refresh(); } } ); toExecute(); }, debounceWaitTime);
export function compileAndWatch(options) { const tsProject = options.tsProject || createTsProjectFromOptions(options); const boundCompile = compile.bind(Object.assign(options, { tsProject })); return series(boundCompile, () => { watch(getCompilePaths(options.compilePaths), {interval: 1000, usePolling: true}, boundCompile) .on('change', () => { log('=== Source change detected. Recompiling...'); }); })(); }
export function compileAndBundle(options) { let startTime = new Date(); return promisify(series( compile.bind(undefined, options.compile || {}), bundle.bind(undefined, options.bundle || {}), (done) => { const completionTime = Math.round((new Date().getTime() - startTime.getTime()) / 1000 * 100) / 100; log('------------------------------------------'); log(`=== Compilation and bundling completed in ${completionTime} sec.`); log('------------------------------------------'); done(); } )); }
let refresh = debounce(() => { if (isBuilding) { log('Watcher: A build is already in progress, deferring change detection...'); return; } isBuilding = true; let paths = pendingRefreshPaths.splice(0); let refreshTasks = []; // Dynamically compose tasks for (let src of Object.keys(watches)) { if (paths.find((x) => minimatch(x, src))) { log(`Watcher: Adding ${watches[src].name} task to next build...`); refreshTasks.push(watches[src].callback); } } if (refreshTasks.length === 0) { log('Watcher: No relevant changes found, skipping next build.'); isBuilding = false; return; } let toExecute = gulp.series( readProjectConfiguration, gulp.parallel(refreshTasks), writeBundles, (done) => { isBuilding = false; watchCallback(); done(); if (pendingRefreshPaths.length > 0) { log('Watcher: Found more pending changes after finishing build, triggering next one...'); refresh(); } } ); toExecute(); }, debounceWaitTime);
gulp.task('build-frontend', (() => { const languages = getLanguages().filter((l) => { return l !== 'en'; }); const tasks = []; createFrontendTask('build-frontend-release default', 'ng build --aot --prod --output-path=./release/dist --no-progress --i18n-locale=en' + ' --i18n-format xlf --i18n-file frontend/' + translationFolder + '/messages.en.xlf' + ' --i18n-missing-translation warning'); tasks.push('build-frontend-release default'); for (let i = 0; i < languages.length; i++) { createFrontendTask('build-frontend-release ' + languages[i], 'ng build --aot --prod --output-path=./release/dist/' + languages[i] + ' --no-progress --i18n-locale=' + languages[i] + ' --i18n-format xlf --i18n-file frontend/' + translationFolder + '/messages.' + languages[i] + '.xlf' + ' --i18n-missing-translation warning'); tasks.push('build-frontend-release ' + languages[i]); } return gulp.series(...tasks); })());
export function compileBundleAndWatch(options) { options = Object.assign({ compile: {}, bundle: {} }, options); const boundCompileAndBundle = () => { return compileAndBundle(options) .then(() => log('==== Watching for changes... ====')); }; return promisify(series( boundCompileAndBundle, () => { return watch(getCompilePaths(options.compile.compilePaths), { interval: 1000, usePolling: true }, boundCompileAndBundle) .on('change', () => { log('=== Source change detected. Recompiling...'); }); })); }
const simpleBuild = (isProd: boolean) => { const languages = getLanguages().filter(function (l) { return l !== 'en'; }); const tasks = []; let cmd = 'ng build --aot '; if (isProd) { cmd += ' --prod --no-extract-licenses '; } createFrontendTask('build-frontend default', cmd + '--output-path=./dist --no-progress --no-progress --i18n-locale en' + ' --i18n-format=xlf --i18n-file=frontend/' + translationFolder + '/messages.en.xlf' + ' --i18n-missing-translation warning'); tasks.push('build-frontend default'); if (!process.env.CI) { // don't build languages if running in CI for (let i = 0; i < languages.length; i++) { createFrontendTask('build-frontend ' + languages[i], cmd + '--output-path=./dist/' + languages[i] + ' --no-progress --i18n-locale ' + languages[i] + ' --i18n-format=xlf --i18n-file=frontend/' + translationFolder + '/messages.' + languages[i] + '.xlf' + ' --i18n-missing-translation warning'); tasks.push('build-frontend ' + languages[i]); } } return gulp.series(...tasks); };