UNPKG

timpla

Version:

An optimal website development experience for [server-side] web frameworks.

59 lines 2.58 kB
"use strict"; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; Object.defineProperty(exports, "__esModule", { value: true }); var gulp = require("gulp"); var internal_1 = require("../../internal"); var assets_1 = require("./assets"); var css_1 = require("./css"); var updateHtml_1 = require("./updateHtml"); var updateReferences_1 = require("./updateReferences"); var revTasks = function (timplaConfig) { var assetsRevEnabled = !!(timplaConfig.staticFiles || timplaConfig.images || timplaConfig.fonts || timplaConfig.svg); var updateReferencesEnabled = !!(timplaConfig.stylesheets || timplaConfig.javascripts); var assets = assetsRevEnabled && assets_1.default(timplaConfig); var updateReferences = updateReferencesEnabled && updateReferences_1.default(timplaConfig); var css = !!timplaConfig.stylesheets && css_1.default(timplaConfig); var updateHtml = !!timplaConfig.html && updateHtml_1.default(timplaConfig); internal_1.setDisplayName(assets, 'assets'); internal_1.setDisplayName(updateReferences, 'updateReferences'); internal_1.setDisplayName(css, 'css'); internal_1.setDisplayName(updateHtml, 'updateHtml'); return [ // 1) Add md5 hashes to assets referenced by CSS and JS files assets, // 2) Update asset references (images, fonts, etc) with reved filenames in compiled css + js updateReferences, // 3) Rev and compress CSS and JS files (this is done after assets, so that if a referenced asset hash changes, the parent hash will change as well css, // 4) Update asset references in HTML updateHtml, ].filter(Boolean); }; // If you are familiar with Rails, this task the equivalent of `rake assets:precompile` exports.rev = function (timplaConfig) { return function (cb) { var toRev = revTasks(timplaConfig); return toRev.length ? gulp.series.apply(gulp, __spread(toRev))(cb) : cb(); }; }; //# sourceMappingURL=index.js.map