@bazzite/nuxt-optimized-images
Advanced tools
Comparing version 0.1.0-beta.2 to 0.1.0
@@ -8,4 +8,2 @@ /** | ||
const consola = require('consola') | ||
const { defaultConfig } = require('./config') | ||
@@ -17,6 +15,3 @@ const { | ||
} = require('./loaders') | ||
const { | ||
missingOptimizePackages, | ||
imageOptimizationInDevMode | ||
} = require('./warning') | ||
const logger = require('./logger') | ||
@@ -29,3 +24,3 @@ function nuxtOptimizedImages (moduleOptions) { | ||
if (dev && options.optimizeImagesInDev) { | ||
imageOptimizationInDevMode() | ||
logger.imageOptimizationInDevMode() | ||
} | ||
@@ -35,3 +30,3 @@ | ||
const detectedLoaders = detectLoaders() | ||
consola.debug('Detected Loaders', detectedLoaders) | ||
logger.debug('Detected Loaders', detectedLoaders) | ||
@@ -44,25 +39,34 @@ // check if it should optimize images in the current state | ||
if (options.optimizeImages && getNumOptimizationLoadersInstalled(detectedLoaders) === 0 && optimizeInCurrentState) { | ||
missingOptimizePackages() | ||
logger.missingOptimizePackages() | ||
} | ||
this.extendBuild((config) => { | ||
const testsRules = [ | ||
// nuxt >= 2 & nuxt <= 2.3.4 | ||
'/\\.(png|jpe?g|gif|svg|webp)$/', | ||
// nuxt >= 2.4.0 | ||
'/\\.(png|jpe?g|gif|svg|webp)$/i' | ||
] | ||
const oldConfig = Object.assign({}, config) | ||
testsRules.forEach(t => { | ||
const rule = config.module.rules.find(r => r.test.toString() === t) | ||
try { | ||
const testsRules = [ | ||
// nuxt >= 2 & nuxt <= 2.3.4 | ||
'/\\.(png|jpe?g|gif|svg|webp)$/', | ||
// nuxt >= 2.4.0 | ||
'/\\.(png|jpe?g|gif|svg|webp)$/i' | ||
] | ||
if (rule) { | ||
config.module.rules.splice(config.module.rules.indexOf(rule), 1) | ||
} else { | ||
consola.debug(`Test Rule couldn't be found: ${t}`) | ||
} | ||
}) | ||
testsRules.forEach(t => { | ||
const rule = config.module.rules.find(r => r.test.toString() === t) | ||
// append loaders | ||
return appendLoaders(config, options, detectedLoaders, optimizeInCurrentState) | ||
if (rule) { | ||
config.module.rules.splice(config.module.rules.indexOf(rule), 1) | ||
} else { | ||
logger.debug(`Test Rule couldn't be found: ${t}`) | ||
} | ||
}) | ||
// append loaders | ||
config = appendLoaders(config, options, detectedLoaders, optimizeInCurrentState) | ||
} catch (error) { | ||
logger.error(error) | ||
config = oldConfig | ||
} | ||
return config | ||
}) | ||
@@ -69,0 +73,0 @@ } |
{ | ||
"name": "@bazzite/nuxt-optimized-images", | ||
"version": "0.1.0-beta.2", | ||
"version": "0.1.0", | ||
"description": "Automatically optimizes images used in Nuxt.js projects (jpeg, png, svg, webp and gif).", | ||
@@ -25,3 +25,2 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"chalk": "^2.4.2", | ||
"consola": "^2.5.6", | ||
@@ -37,7 +36,7 @@ "imagemin": "^6.1.0", | ||
"conventional-changelog-cli": "^2.0.12", | ||
"eslint": "^5.14.1", | ||
"eslint": "^5.15.1", | ||
"eslint-config-dev": "^2.0.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-jest": "^22.3.0", | ||
"eslint-plugin-jest": "^22.3.2", | ||
"eslint-plugin-node": "^8.0.1", | ||
@@ -52,3 +51,3 @@ "eslint-plugin-promise": "^4.0.1", | ||
"imagemin-svgo": "^7.0.0", | ||
"jest": "^24.1.0", | ||
"jest": "^24.5.0", | ||
"jimp": "^0.6.0", | ||
@@ -61,3 +60,3 @@ "loader-utils": "^1.2.3", | ||
"sharp": "^0.21.3", | ||
"upath": "^1.1.0", | ||
"upath": "^1.1.2", | ||
"webp-loader": "^0.4.0" | ||
@@ -64,0 +63,0 @@ }, |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
5
24
36283
714
1
- Removedchalk@^2.4.2
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)