Browse Source

Modified Gulp file to also bundle and minify based on the bundle config

tags/3.0.0^2
Teknikode 1 year ago
parent
commit
e795043aef
5 changed files with 108 additions and 128 deletions
  1. 2
    8
      Teknik/bundleconfig.json
  2. 0
    1
      Teknik/bundleconfig.json.bindings
  3. 60
    4
      Teknik/gulpfile.js
  4. 42
    112
      Teknik/package-lock.json
  5. 4
    3
      Teknik/package.json

+ 2
- 8
Teknik/bundleconfig.json View File

@@ -127,19 +127,13 @@
"wwwroot/lib/crypto-js/js/mode-ctr.js",
"wwwroot/lib/crypto-js/js/lib-typedarrays.js",
"wwwroot/lib/crypto-js/js/pad-nopadding.js"
],
"minify": {
"enabled": false
}
]
},
{
"outputFileName": "wwwroot/js/cryptoWorker.min.js",
"inputFiles": [
"wwwroot/js/app/Upload/EncryptionWorker.js"
],
"minify": {
"enabled": false
}
]
},
{
"outputFileName": "wwwroot/js/upload.min.js",

+ 0
- 1
Teknik/bundleconfig.json.bindings View File

@@ -1 +0,0 @@
///<binding BeforeBuild='Update all files' Clean='Clean output files' />

+ 60
- 4
Teknik/gulpfile.js View File

@@ -1,14 +1,17 @@
/// <binding BeforeBuild='copy-assets' Clean='clean' />
/// <binding ProjectOpened='watch' />
"use strict";

var gulp = require('gulp');
var rimraf = require("rimraf");
var concat = require("gulp-concat");
var cssmin = require("gulp-cssmin");
var htmlmin = require("gulp-htmlmin");
var uglify = require("gulp-uglify");
var merge = require('merge-stream');
var del = require("del");

var uglifyes = require('uglify-es');
var composer = require('gulp-uglify/composer');
var uglify = composer(uglifyes, console);

var bundleconfig = require("./bundleconfig.json");

var regex = {
@@ -75,4 +78,57 @@ gulp.task('copy-assets', function () {
streams.push(gulp.src(item).pipe(gulp.dest('wwwroot/' + assets[asset][item])));
}
}
});
});

gulp.task("load-bundle", function () {
bundleconfig = require("./bundleconfig.json");
});

gulp.task("min", ["min:js", "min:css"]);

gulp.task("min:js", function () {
var tasks = getBundles(".js").map(function (bundle) {
return gulp.src(bundle.inputFiles, { base: "." })
.pipe(concat(bundle.outputFileName))
.pipe(uglify())
.pipe(gulp.dest("."));
});
return merge(tasks);
});

gulp.task("min:css", function () {
var tasks = getBundles(".css").map(function (bundle) {
return gulp.src(bundle.inputFiles, { base: "." })
.pipe(concat(bundle.outputFileName))
.pipe(cssmin())
.pipe(gulp.dest("."));
});
return merge(tasks);
});

gulp.task("watch", function () {
// Watch Source Files
assets.forEach(function (src) {
for (var key in src) {
gulp.watch(key, ["copy-assets"]);
}
});

// Watch Bundle File Itself
gulp.watch('./bundleconfig.json', ["load-bundle", "min"]);

// Watch Bundles
getBundles(".js").forEach(function (bundle) {
gulp.watch(bundle.inputFiles, ["min:js"]);
});

getBundles(".css").forEach(function (bundle) {
gulp.watch(bundle.inputFiles, ["min:css"]);
});
});

function getBundles(extension) {
return bundleconfig.filter(function (bundle) {
return new RegExp(`${extension}$`).test(bundle.outputFileName);
});
}

+ 42
- 112
Teknik/package-lock.json View File

@@ -251,15 +251,6 @@
}
}
},
"bufferstreams": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz",
"integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==",
"dev": true,
"requires": {
"readable-stream": "2.3.6"
}
},
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
@@ -283,16 +274,6 @@
"unset-value": "1.0.0"
}
},
"camel-case": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz",
"integrity": "sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M=",
"dev": true,
"requires": {
"no-case": "2.3.2",
"upper-case": "1.1.3"
}
},
"camelcase": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz",
@@ -663,6 +644,15 @@
}
}
},
"end-of-stream": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
"dev": true,
"requires": {
"once": "1.4.0"
}
},
"entities": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
@@ -1445,20 +1435,6 @@
}
}
},
"gulp-htmlmin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/gulp-htmlmin/-/gulp-htmlmin-3.0.0.tgz",
"integrity": "sha1-GeqAAtEjHWsfGKEtIPKmand3D7M=",
"dev": true,
"requires": {
"bufferstreams": "1.1.3",
"gulp-util": "3.0.8",
"html-minifier": "3.5.16",
"object-assign": "4.1.1",
"readable-stream": "2.3.6",
"tryit": "1.0.3"
}
},
"gulp-rename": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz",
@@ -1604,12 +1580,6 @@
}
}
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"highcharts": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/highcharts/-/highcharts-6.1.0.tgz",
@@ -1635,38 +1605,6 @@
"integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==",
"dev": true
},
"html-minifier": {
"version": "3.5.16",
"resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.16.tgz",
"integrity": "sha512-zP5EfLSpiLRp0aAgud4CQXPQZm9kXwWjR/cF0PfdOj+jjWnOaCgeZcll4kYXSvIBPeUMmyaSc7mM4IDtA+kboA==",
"dev": true,
"requires": {
"camel-case": "3.0.0",
"clean-css": "4.1.11",
"commander": "2.15.1",
"he": "1.1.1",
"param-case": "2.1.1",
"relateurl": "0.2.7",
"uglify-js": "3.3.28"
},
"dependencies": {
"clean-css": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.1.11.tgz",
"integrity": "sha1-Ls3xRaujj1R0DybO/Q/z4D4SXWo=",
"dev": true,
"requires": {
"source-map": "0.5.7"
}
},
"commander": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
}
}
},
"htmlparser2": {
"version": "3.9.2",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz",
@@ -2279,12 +2217,6 @@
"signal-exit": "3.0.2"
}
},
"lower-case": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz",
"integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw=",
"dev": true
},
"make-error": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
@@ -2483,15 +2415,6 @@
"integrity": "sha1-Lw8iT8mn3VNAfHZnyEz42+dz3lg=",
"dev": true
},
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
"integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==",
"dev": true,
"requires": {
"lower-case": "1.1.4"
}
},
"normalize-package-data": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
@@ -2666,15 +2589,6 @@
"integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==",
"dev": true
},
"param-case": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz",
"integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=",
"dev": true,
"requires": {
"no-case": "2.3.2"
}
},
"parse-filepath": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz",
@@ -2849,6 +2763,16 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
},
"pump": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
"dev": true,
"requires": {
"end-of-stream": "1.4.1",
"once": "1.4.0"
}
},
"read-pkg": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
@@ -2913,12 +2837,6 @@
"safe-regex": "1.1.0"
}
},
"relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=",
"dev": true
},
"remove-trailing-separator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
@@ -3463,11 +3381,29 @@
"integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=",
"dev": true
},
"tryit": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz",
"integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=",
"dev": true
"uglify-es": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"requires": {
"commander": "2.13.0",
"source-map": "0.6.1"
},
"dependencies": {
"commander": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"uglify-js": {
"version": "3.3.28",
@@ -3580,12 +3516,6 @@
}
}
},
"upper-case": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz",
"integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg=",
"dev": true
},
"urix": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",

+ 4
- 3
Teknik/package.json View File

@@ -24,10 +24,11 @@
"gulp": "3.9.1",
"gulp-concat": "^2.6.1",
"gulp-cssmin": "^0.2.0",
"gulp-htmlmin": "^3.0.0",
"gulp-uglify": "^3.0.0",
"merge-stream": "^1.0.1",
"rimraf": "^2.6.2"
"pump": "^3.0.0",
"rimraf": "^2.6.2",
"uglify-es": "^3.3.9"
},
"keywords": [
"Teknik",
@@ -43,7 +44,7 @@
"url": "https://git.teknik.io/Teknikode/TeknikCore"
},
"scripts": {
"pre-publish": "npm install && gulp clean && gulp copy-assets"
"pre-publish": "npm install && gulp clean && gulp copy-assets && gulp watch"
},
"version": "2.1.0",
"-vs-binding": {

Loading…
Cancel
Save