-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·44 lines (34 loc) · 1.39 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
/* eslint-disable import/no-extraneous-dependencies */
/**
* shortbread is an asynchronous, non-blocking loading pattern for CSS and JavaScript resources
*
* @see https://github.com/jkphl/shortbread
*
* @author Joschi Kuphal <[email protected]> (https://github.com/jkphl)
* @copyright © 2019 Joschi Kuphal
* @license MIT https://raw.github.com/jkphl/gulp-cache-bust-meta/master/LICENSE
*/
const gulp = require('gulp');
const shortbread = require('.').stream;
const vinyl = require('vinyl-file');
const path = require('path');
const filter = require('gulp-filter');
const template = require('gulp-template');
gulp.task('default', (done) => {
const criticalJS = vinyl.readSync('test/fixtures/critical.js');
const criticalCSS = vinyl.readSync('test/fixtures/critical.css');
const tmpl = filter(['**/*.php'], { restore: true });
// Start with your JavaScript, CSS and template resources
gulp.src(['**/fixtures/*.js', '**/fixtures/style.css', 'gulp/*.php'], { cwd: path.join(__dirname, 'test') })
// Run shortbread
.pipe(shortbread([criticalJS, criticalCSS], 'main', null, { prefix: '/' }))
// Filter all but the template file
.pipe(tmpl)
// Run the template engine
.pipe(template())
// Restore all files
.pipe(tmpl.restore)
// Write the files to their destination
.pipe(gulp.dest('./tmp'));
done();
});