-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
executable file
·63 lines (53 loc) · 1.95 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const path = require('path');
const gulp = require('gulp');
const fileinclude = require('gulp-file-include');
const browserSync = require('browser-sync').create();
// Pull in optional configuration from the package.json file, a la:
const {componentPath, componentDirectories, buildDestionation} = require('@visual-framework/vf-config');
// Tasks to build/run vf-core component system
require('./node_modules/\@visual-framework/vf-core/gulp-tasks/_gulp_rollup.js')(gulp, path, componentPath, componentDirectories, buildDestionation);
require('./node_modules/\@visual-framework/vf-extensions/gulp-tasks/_gulp_rollup.js')(gulp, path, componentPath, componentDirectories, buildDestionation);
// Watch folders for changes
gulp.task('watch', function() {
gulp.watch(['./src/pages/**/*'], gulp.parallel('build-assets', 'build-html'));
gulp.watch(['./build/**/*'], gulp.series('browser-reload'));
});
gulp.task('build-html', function() {
return gulp.src('./src/pages/**/*.html') // important: only on html files
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest(buildDestionation));
});
// Copy local assets to the build directory
gulp.task('build-assets', function() {
return gulp.src(['./src/pages/**/*','!./src/pages/**/*.html'])
.pipe(gulp.dest(buildDestionation));
});
// Serve locally
gulp.task('browser-sync', function(done) {
browserSync.init({
server: {
baseDir: buildDestionation,
index: '/index.html'
}
});
done();
});
gulp.task('browser-reload', function(done) {
browserSync.reload();
done();
});
// Let's build this sucker.
gulp.task('build', gulp.series(
'vf-clean',
gulp.parallel('build-assets','build-html','vf-css','vf-scripts','vf-component-assets')
));
// Build and watch things during dev
gulp.task('dev', gulp.series(
'vf-clean',
gulp.parallel('build-assets','build-html','vf-css','vf-scripts','vf-component-assets'),
'browser-sync',
gulp.parallel('watch','vf-watch')
));