UNPKG

simplr-gulp

Version:

Fully functional gulpfile.js implementation. Tailored for Single Page Application. Written in TypeScript.

41 lines (40 loc) 1.88 kB
Object.defineProperty(exports, "__esModule", { value: true }); const task_base_1 = require("../task-base"); const jspm = require("jspm"); const configuration_1 = require("../../configuration/configuration"); const paths_1 = require("../../paths/paths"); const path = require("path"); const logger_1 = require("../../utils/logger"); const fs = require("fs"); class BundleTask extends task_base_1.TaskBase { constructor() { super(...arguments); this.Name = "Bundle"; this.Description = "Bundles the app libs with jspm bundle"; this.TaskFunction = (production, done) => { let { BundleConfig } = configuration_1.Configuration.GulpConfig; let appFile = path.join(configuration_1.Configuration.GulpConfig.Directories.App, BundleConfig.AppFile).split(path.sep).join("/"); let bundleCmd = appFile, buildDest = paths_1.Paths.Builders.OneFile.InBuild(BundleConfig.BuildFile); for (let i = 0; i < BundleConfig.Include.length; i++) { bundleCmd += ` + ${BundleConfig.Include[i]}`; } for (let i = 0; i < BundleConfig.Exclude.length; i++) { bundleCmd += ` - ${BundleConfig.Exclude[i]}`; } let builder = new jspm.Builder(); logger_1.LoggerInstance.log(`jspm bundle ${bundleCmd} ${buildDest}`); builder.bundle(bundleCmd, { minify: true, mangle: true }).then((output) => { fs.writeFileSync(buildDest, output.source); done(); }).catch((e) => { done(); logger_1.LoggerInstance.info("Please make sure that you have installed jspm packages ('jspm install')"); throw e; }); }; } } exports.BundleTask = BundleTask;