@nitro/gulp 6.0.10 → 6.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/lib/utils.js CHANGED
@@ -23,6 +23,17 @@ function getProjectPath() {
23
23
  return config.get('nitro.basePath');
24
24
  }
25
25
 
26
+ // load optional package
27
+ function getOptionalPackage(x) {
28
+ let mod;
29
+ try {
30
+ mod = require(x);
31
+ } catch (error) {
32
+ mod = null;
33
+ }
34
+ return mod;
35
+ }
36
+
26
37
  function each(cfgs, fn) {
27
38
  if (cfgs.length) {
28
39
  cfgs.forEach((cfg) => {
@@ -37,5 +48,6 @@ module.exports = {
37
48
  getBrowserSyncInstance,
38
49
  getTask,
39
50
  getProjectPath,
51
+ getOptionalPackage,
40
52
  each,
41
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitro/gulp",
3
- "version": "6.0.10",
3
+ "version": "6.1.1",
4
4
  "description": "Nitro gulp",
5
5
  "license": "MIT",
6
6
  "author": "The Nitro Team",
@@ -23,7 +23,7 @@
23
23
  "gulp"
24
24
  ],
25
25
  "peerDependencies": {
26
- "@nitro/app": ">=6.0.10",
26
+ "@nitro/app": ">=6.1.1",
27
27
  "gulp": ">=4.0.2"
28
28
  },
29
29
  "dependencies": {
@@ -34,7 +34,7 @@
34
34
  "get-port": "5.1.1",
35
35
  "globby": "11.0.4",
36
36
  "gulp": "4.0.2",
37
- "gulp-htmllint": "0.0.19",
37
+ "gulp-html-validate": "0.2.0",
38
38
  "gulp-imagemin": "7.1.0",
39
39
  "gulp-live-server": "0.0.31",
40
40
  "gulp-load-plugins": "2.0.7",
@@ -44,8 +44,9 @@
44
44
  "gulp-rename": "2.0.0",
45
45
  "gulp-svgmin": "4.1.0",
46
46
  "gulp-svgstore": "9.0.0",
47
+ "html-validate": "6.9.0",
47
48
  "merge-stream": "2.0.0",
48
- "yargs": "17.4.0"
49
+ "yargs": "17.4.1"
49
50
  },
50
51
  "optionalDependencies": {
51
52
  "imagemin-pngquant": "9.0.2"
@@ -54,7 +55,7 @@
54
55
  "@namics/eslint-config": "9.1.1",
55
56
  "@nitro/app": "*",
56
57
  "eslint": "7.32.0",
57
- "eslint-plugin-import": "2.25.4"
58
+ "eslint-plugin-import": "2.26.0"
58
59
  },
59
60
  "publishConfig": {
60
61
  "access": "public"
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const lint = require('@nitro/app/app/lib/lint');
4
3
  const config = require('config');
5
4
  const srcPattern = `${config.get('nitro.tmpDirectory')}/views/*.html`;
6
5
 
@@ -8,7 +7,9 @@ module.exports = (gulp, plugins) => {
8
7
  return () => {
9
8
  return gulp
10
9
  .src(srcPattern)
11
- .pipe(plugins.htmllint({}, lint.htmllintReporter))
10
+ .pipe(plugins.htmlValidate())
11
+ .pipe(plugins.htmlValidate.format())
12
+ .pipe(plugins.htmlValidate.failAfterError())
12
13
  .on('end', () => {});
13
14
  };
14
15
  };
@@ -1,15 +1,54 @@
1
1
  'use strict';
2
2
 
3
3
  const config = require('config');
4
- const pngquant = require('imagemin-pngquant');
5
4
  const merge = require('merge-stream');
6
5
  const utils = require('../lib/utils');
7
6
 
8
7
  module.exports = (gulp, plugins) => {
8
+ /* eslint-disable complexity */
9
9
  return () => {
10
10
  const minifyImagesConfigs = config.has('gulp.minifyImages') ? config.get('gulp.minifyImages') : {};
11
11
  const streams = [];
12
12
 
13
+ const imageminMozjpeg = utils.getOptionalPackage('imagemin-mozjpeg');
14
+ const imageminOptipng = utils.getOptionalPackage('imagemin-optipng');
15
+ const imageminPngquant = utils.getOptionalPackage('imagemin-pngquant');
16
+ const imageminSvgo = utils.getOptionalPackage('imagemin-svgo');
17
+ const imageminPluginsConfig = [];
18
+
19
+ // console.log('imagemin-mozjpeg: ', imageminMozjpeg ? 'installed' : 'NOT');
20
+ // console.log('imagemin-optipng: ', imageminOptipng ? 'installed' : 'NOT');
21
+ // console.log('imagemin-pngquant: ', imageminPngquant ? 'installed' : 'NOT');
22
+ // console.log('imagemin-svgo: ', imageminSvgo ? 'installed' : 'NOT');
23
+
24
+ if (imageminMozjpeg) {
25
+ imageminPluginsConfig.push(
26
+ plugins.imagemin.mozjpeg({ quality: 75, progressive: true })
27
+ );
28
+ }
29
+ if (imageminOptipng) {
30
+ imageminPluginsConfig.push(
31
+ plugins.imagemin.optipng({ optimizationLevel: 7 })
32
+ );
33
+ }
34
+ if (imageminSvgo) {
35
+ imageminPluginsConfig.push(
36
+ plugins.imagemin.svgo({
37
+ plugins: [
38
+ { collapseGroups: false },
39
+ { cleanupIDs: false },
40
+ { removeUnknownsAndDefaults: false },
41
+ { removeViewBox: false },
42
+ ],
43
+ })
44
+ );
45
+ }
46
+ if (imageminPngquant) {
47
+ imageminPluginsConfig.push(
48
+ imageminPngquant()
49
+ );
50
+ }
51
+
13
52
  utils.each(minifyImagesConfigs, (minifyImagesConfig) => {
14
53
  if (minifyImagesConfig && minifyImagesConfig.src && minifyImagesConfig.dest) {
15
54
  streams.push(
@@ -17,19 +56,7 @@ module.exports = (gulp, plugins) => {
17
56
  .src(minifyImagesConfig.src)
18
57
  .pipe(plugins.newer(minifyImagesConfig.dest))
19
58
  .pipe(
20
- plugins.imagemin([
21
- plugins.imagemin.mozjpeg({ quality: 75, progressive: true }),
22
- plugins.imagemin.optipng({ optimizationLevel: 7 }),
23
- plugins.imagemin.svgo({
24
- plugins: [
25
- { collapseGroups: false },
26
- { cleanupIDs: false },
27
- { removeUnknownsAndDefaults: false },
28
- { removeViewBox: false },
29
- ],
30
- }),
31
- pngquant(),
32
- ])
59
+ plugins.imagemin(imageminPluginsConfig)
33
60
  )
34
61
  .pipe(gulp.dest(minifyImagesConfig.dest))
35
62
  );
@@ -38,4 +65,5 @@ module.exports = (gulp, plugins) => {
38
65
 
39
66
  return streams.length ? merge(...streams) : Promise.resolve('resolved');
40
67
  };
68
+ /* eslint-enable complexity */
41
69
  };