Skip to content

Commit

Permalink
fix(index): update validation schema, better warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed May 10, 2017
1 parent 3963860 commit 4f20c99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
9 changes: 4 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path')
const loaderUtils = require('loader-utils')

const parseOptions = require('./options')
const validateOptions = require('schema-utils') // eslint-disable-line
const validateOptions = require('schema-utils')

const postcss = require('postcss')
const postcssrc = require('postcss-load-config')
Expand Down Expand Up @@ -45,8 +45,7 @@ module.exports = function loader (css, map) {

const options = loaderUtils.getOptions(this) || {}

// TODO
// validateOptions('./node_modules/postcss-loader/lib/options.json', options, 'PostCSS Loader')
validateOptions(require('./options.json'), options, 'PostCSS Loader')

const rc = {
path: '',
Expand Down Expand Up @@ -75,7 +74,7 @@ module.exports = function loader (css, map) {
const length = Object.keys(options).length

// TODO
// Deuglify
// Refactor
if (!options.config && !sourceMap && length) {
return parseOptions.call(this, options)
} else if (options.config && !sourceMap && length > 1) {
Expand Down Expand Up @@ -128,7 +127,7 @@ module.exports = function loader (css, map) {
}

if (!sourceMap && map) {
this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set, this way the loader will discard the source map enterily for performance reasons, see https://github.com/postcss/postcss-loader#sourcemap for more info on the subject\n\n`)
this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set.\nIn this case the loader will discard the source map enterily for performance reasons.\nSee https://github.com/postcss/postcss-loader#sourcemap for more information.\n\n`)
}

if (sourceMap && typeof map === 'string') map = JSON.parse(map)
Expand Down
9 changes: 3 additions & 6 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"additionalProperties": false
},
"exec": {
"type": "boolean"
},
"parser": {
"type": "string"
},
Expand All @@ -24,12 +27,6 @@
},
"sourceMap": {
"type": [ "string", "boolean" ]
},
"exec": {
"type": "boolean"
},
"rewrite": {
"type": "boolean"
}
},
"additionalProperties": true
Expand Down

0 comments on commit 4f20c99

Please sign in to comment.