Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #203 from anikethsaha/add/schema-utils
Browse files Browse the repository at this point in the history
chore: added schema validations
  • Loading branch information
tcoopman committed Dec 8, 2019
2 parents 02b4649 + 909bcf6 commit ec52037
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 74 deletions.
8 changes: 7 additions & 1 deletion index.js
@@ -1,7 +1,9 @@
var imagemin = require('imagemin');
var loaderUtils = require('loader-utils');
var assign = require('object-assign');
var schemaValidation = require('schema-utils')

var loaderSchema = require('./schema.json')
/**
* Basically the getLoaderConfig() function from loader-utils v0.2.
*/
Expand Down Expand Up @@ -37,7 +39,7 @@ module.exports = function(content) {
optipng: config.optipng || {},
svgo: config.svgo || {},
// optional optimizers
webp: config.webp || null
webp: config.webp || {}
};
// Remove in interlaced, progressive and optimizationLevel checks in new major version
if (config.hasOwnProperty('interlaced')) {
Expand All @@ -53,6 +55,10 @@ module.exports = function(content) {
this.emitWarning("DEPRECATED. Configure optipng's optimizationLevel option in its own options. (optipng.optimizationLevel)");
}

schemaValidation(loaderSchema, options, {
name: 'imageWebpackLoader'
});

var callback = this.async(),
called = false;

Expand Down
169 changes: 99 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec52037

Please sign in to comment.