Skip to content

Commit 3d668f5

Browse files
committed
GCX CSS&JS updates
08-gcx-js integrated into site.js enlighterjs integrated into the build css enlighte integrated tinto site.css minor updates gcx-full layout
1 parent c294384 commit 3d668f5

File tree

10 files changed

+5432
-382
lines changed

10 files changed

+5432
-382
lines changed

gulp.d/tasks/build.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,38 @@ module.exports = (src, dest, preview) => () => {
5858
.pipe(terser())
5959
// NOTE concat already uses stat from newest combined file
6060
.pipe(concat('js/site.js')),
61+
vfs
62+
.src('js/vendor/enlighterjs/*.js', { ...opts, read: false })
63+
.pipe(
64+
// see https://gulpjs.org/recipes/browserify-multiple-destination.html
65+
map((file, enc, next) => {
66+
if (file.relative.endsWith('.bundle.js')) {
67+
const mtimePromises = []
68+
const bundlePath = file.path
69+
browserify(file.relative, { basedir: src, detectGlobals: false })
70+
.plugin('browser-pack-flat/plugin')
71+
.on('file', (bundledPath) => {
72+
if (bundledPath !== bundlePath) mtimePromises.push(fs.stat(bundledPath).then(({ mtime }) => mtime))
73+
})
74+
.bundle((bundleError, bundleBuffer) =>
75+
Promise.all(mtimePromises).then((mtimes) => {
76+
const newestMtime = mtimes.reduce((max, curr) => (!max || curr > max ? curr : max))
77+
if (newestMtime > file.stat.mtime) file.stat.mtimeMs = +(file.stat.mtime = newestMtime)
78+
if (bundleBuffer !== undefined) file.contents = bundleBuffer
79+
file.path = file.path.slice(0, file.path.length - 10) + '.js'
80+
next(bundleError, file)
81+
})
82+
)
83+
} else {
84+
fs.readFile(file.path, 'UTF-8').then((contents) => {
85+
file.contents = Buffer.from(contents)
86+
next(null, file)
87+
})
88+
}
89+
})
90+
)
91+
.pipe(buffer())
92+
.pipe(terser()),
6193
vfs
6294
.src('js/vendor/gcx-contact-form/*.js', { ...opts, read: false })
6395
.pipe(

0 commit comments

Comments
 (0)