Skip to content

Commit 4f20c99

Browse files
fix(index): update validation schema, better warning message
1 parent 3963860 commit 4f20c99

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

lib/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path')
55
const loaderUtils = require('loader-utils')
66

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

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

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

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

5150
const rc = {
5251
path: '',
@@ -75,7 +74,7 @@ module.exports = function loader (css, map) {
7574
const length = Object.keys(options).length
7675

7776
// TODO
78-
// Deuglify
77+
// Refactor
7978
if (!options.config && !sourceMap && length) {
8079
return parseOptions.call(this, options)
8180
} else if (options.config && !sourceMap && length > 1) {
@@ -128,7 +127,7 @@ module.exports = function loader (css, map) {
128127
}
129128

130129
if (!sourceMap && map) {
131-
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`)
130+
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`)
132131
}
133132

134133
if (sourceMap && typeof map === 'string') map = JSON.parse(map)

lib/options.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
},
1414
"additionalProperties": false
1515
},
16+
"exec": {
17+
"type": "boolean"
18+
},
1619
"parser": {
1720
"type": "string"
1821
},
@@ -24,12 +27,6 @@
2427
},
2528
"sourceMap": {
2629
"type": [ "string", "boolean" ]
27-
},
28-
"exec": {
29-
"type": "boolean"
30-
},
31-
"rewrite": {
32-
"type": "boolean"
3330
}
3431
},
3532
"additionalProperties": true

0 commit comments

Comments
 (0)