autofront 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +24 -3
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ The Gulp ones are:
|
|
|
49
49
|
| Name | Details | Processes |
|
|
50
50
|
| --- | --- | --- |
|
|
51
51
|
| `serve` (default) | Source code runs in a server with live reload. | <ul><li>Bower entry-point files catching.</li><li>Notification and injection of [environment](#environment-variables).</li><li>Compilation (Less, SCSS and Pug)[^1].</li><li>Set up[^2] of HTML5 mode.[^1]</li><li>Insertion of file with app info (`about.json`).</li></ul> |
|
|
52
|
-
| `build` | Production code is built (in folder `dist`). | The above and: <ul><li>Templates caching.[^1]</li><li>Concatenation to one hashed file (CSS and JS).</li><li>Minification (HTML, CSS, JS, images and JSON).</li><li>Console display of files size.</li></ul> |
|
|
52
|
+
| `build` | Production code is built (in folder `dist`). | The above and: <ul><li>Templates caching.[^1]</li><li>Concatenation to one hashed file (CSS and JS).</li><li>CSS purging.</li><li>Transform to compatible CSS (Autoprefixer) and JS (Babel).</li><li>Minification (HTML, CSS, JS, images and JSON).</li><li>Console display of files size.</li></ul> |
|
|
53
53
|
| `serve:dist` | This distributable application is served but without the refreshing. | The same with the folder hidden. |
|
|
54
54
|
|
|
55
55
|
[^1]: [If it is on](#settings).
|
package/index.js
CHANGED
|
@@ -34,6 +34,7 @@ const gulp = require('gulp'),
|
|
|
34
34
|
browserSync = require('browser-sync').create(),
|
|
35
35
|
deleteEmpty = require('delete-empty'),
|
|
36
36
|
gulpHtmlmin = () => $.htmlmin({ collapseWhitespace: true, conservativeCollapse: true }),
|
|
37
|
+
gulpPostcss = name => $.postcss([require(name)()]),
|
|
37
38
|
fs = require('fs'),
|
|
38
39
|
hidefile = require('hidefile');
|
|
39
40
|
|
|
@@ -336,6 +337,13 @@ function indexDist() {
|
|
|
336
337
|
}
|
|
337
338
|
indexDist.displayName = 'index:dist';
|
|
338
339
|
|
|
340
|
+
function purgeCss() {
|
|
341
|
+
return gulp.src(globs.dist + cssFile)
|
|
342
|
+
.pipe($.purgecss({ content: [globs.dist + getGlob('html')] }))
|
|
343
|
+
.pipe(gulp.dest(globs.dist));
|
|
344
|
+
}
|
|
345
|
+
purgeCss.displayName = 'purge-css';
|
|
346
|
+
|
|
339
347
|
function rebase() {
|
|
340
348
|
const str = 'url(',
|
|
341
349
|
quotes = ["'", '"'];
|
|
@@ -371,9 +379,14 @@ const clean = gulp.series(cleanFiles, cleanFolders);
|
|
|
371
379
|
|
|
372
380
|
const rebaseAndClean = gulp.parallel(rebase, clean);
|
|
373
381
|
|
|
382
|
+
const compatible = gulp.parallel(
|
|
383
|
+
getCompatibleTask('css', stream => stream.pipe(gulpPostcss('autoprefixer'))),
|
|
384
|
+
getCompatibleTask('js', stream => stream.pipe($.babel({ presets: ['@babel/preset-env'], compact: false })))
|
|
385
|
+
);
|
|
386
|
+
|
|
374
387
|
const minify = gulp.parallel(
|
|
375
388
|
getMinifyTask('html', stream => stream.pipe(gulpHtmlmin())),
|
|
376
|
-
getMinifyTask('css', stream => stream.pipe(
|
|
389
|
+
getMinifyTask('css', stream => stream.pipe(gulpPostcss('cssnano'))),
|
|
377
390
|
getMinifyTask('js', stream => {
|
|
378
391
|
if (getSetting('ng'))
|
|
379
392
|
stream = stream.pipe($.ngAnnotate());
|
|
@@ -396,7 +409,7 @@ finishBuild.displayName = 'finish-build';
|
|
|
396
409
|
gulp.task('build', gulp.series(
|
|
397
410
|
setVariables,
|
|
398
411
|
gulp.parallel(buildTmp, removeFolderDist),
|
|
399
|
-
copy, templates, indexDist, rebaseAndClean, minify, finishBuild
|
|
412
|
+
copy, templates, indexDist, purgeCss, rebaseAndClean, compatible, minify, finishBuild
|
|
400
413
|
));
|
|
401
414
|
|
|
402
415
|
function hideFolderDist(cb) {
|
|
@@ -528,9 +541,17 @@ function browserSyncInit(path) {
|
|
|
528
541
|
browserSync.init({ server: path });
|
|
529
542
|
}
|
|
530
543
|
|
|
544
|
+
function getCompatibleTask(ext, getProcessedStream) {
|
|
545
|
+
return getProcessingTask('compatible', ext, getProcessedStream);
|
|
546
|
+
}
|
|
547
|
+
|
|
531
548
|
function getMinifyTask(ext, getProcessedStream, str) {
|
|
549
|
+
return getProcessingTask('minify', ext, getProcessedStream, str);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function getProcessingTask(prefix, ext, getProcessedStream, str) {
|
|
532
553
|
const fn = () => getProcessedStream(gulp.src(globs.dist + getGlob(ext)))
|
|
533
554
|
.pipe(gulp.dest(globs.dist));
|
|
534
|
-
fn.displayName = '
|
|
555
|
+
fn.displayName = prefix + '-' + (str || ext);
|
|
535
556
|
return fn;
|
|
536
557
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autofront",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Automation of front-end by Gulp and Bower.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/mvicens/autofront#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@babel/core": "7.20.5",
|
|
32
|
+
"@babel/preset-env": "7.20.2",
|
|
33
|
+
"autoprefixer": "10.4.13",
|
|
31
34
|
"browser-sync": "2.27.10",
|
|
32
35
|
"cssnano": "5.1.14",
|
|
33
36
|
"delete-empty": "2.0.0",
|
|
@@ -37,6 +40,7 @@
|
|
|
37
40
|
"gulp-add-files": "1.0.0",
|
|
38
41
|
"gulp-angular-filesort": "1.2.1",
|
|
39
42
|
"gulp-angular-templatecache": "3.0.1",
|
|
43
|
+
"gulp-babel": "8.0.0",
|
|
40
44
|
"gulp-clean": "0.4.0",
|
|
41
45
|
"gulp-cssimport": "7.0.0",
|
|
42
46
|
"gulp-filter": "7.0.0",
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"gulp-notify": "4.0.0",
|
|
52
56
|
"gulp-postcss": "9.0.1",
|
|
53
57
|
"gulp-pug": "5.0.0",
|
|
58
|
+
"gulp-purgecss": "5.0.0",
|
|
54
59
|
"gulp-rename": "2.0.0",
|
|
55
60
|
"gulp-rev": "9.0.0",
|
|
56
61
|
"gulp-rev-delete-original": "0.2.3",
|