wishthis/node_modules/fomantic-ui/tasks/docs/serve.js

98 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

2022-01-13 13:00:31 +00:00
/*******************************
Serve Docs
*******************************/
2023-08-17 09:47:40 +00:00
const
extend = require('extend'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// node dependencies
console = require('better-console'),
gulp = require('gulp'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// gulp dependencies
print = require('gulp-print').default,
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// user config
configDocs = require('../config/docs'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// task config
tasks = require('../config/tasks'),
configSetup = require('../config/project/config'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// shorthand
log = tasks.log,
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
css = require('../build/css'),
js = require('../build/javascript'),
assets = require('../build/assets')
;
2022-01-13 13:00:31 +00:00
module.exports = function () {
2023-08-17 09:47:40 +00:00
// use a different config
const config = extend(true, {}, configDocs);
configSetup.addDerivedValues(config);
console.clear();
console.log('Watching source files for changes');
/* --------------
Copy Source
--------------- */
gulp
.watch(['src/**/*.*'])
.on('all', function (event, path) {
// We don't handle deleted files yet
if (event === 'unlink' || event === 'unlinkDir') {
return;
}
return gulp.src(path, {
base: 'src/',
})
.pipe(gulp.dest(config.paths.output.less))
.pipe(print(log.created))
;
})
;
/* --------------
Copy Examples
--------------- */
gulp
.watch(['examples/**/*.*'])
.on('all', function (event, path) {
// We don't handle deleted files yet
if (event === 'unlink' || event === 'unlinkDir') {
return;
}
return gulp.src(path, {
base: 'examples/',
})
.pipe(gulp.dest(config.paths.output.examples))
.pipe(print(log.created))
;
})
;
/* --------------
Watch CSS
--------------- */
css.watch('docs', config);
/* --------------
Watch JS
--------------- */
js.watch('docs', config);
/* --------------
Watch Assets
--------------- */
assets.watch('docs', config);
2022-01-13 13:00:31 +00:00
};