33 Author Tobias Koppers @sokra
44*/
55
6+ const schema = require ( "./options.json" ) ;
7+ const validate = require ( "@webpack-contrib/schema-utils" ) ;
68const loaderUtils = require ( "loader-utils" ) ;
79const postcss = require ( "postcss" ) ;
810const plugin = require ( "./plugin" ) ;
@@ -11,13 +13,14 @@ const SyntaxError = require("./SyntaxError");
1113module . exports = function ( content , map , meta ) {
1214 const options = loaderUtils . getOptions ( this ) || { } ;
1315
14- // Todo validate options
16+ validate ( { name : "CSS Loader" , schema , target : options } ) ;
1517
1618 const cb = this . async ( ) ;
17- const sourceMap = options . sourceMap || false ;
18- const url = typeof options . url === "undefined" ? true : options . url ;
19- const importOpt = typeof options . import === "undefined" ? true : options . import ;
20- const importLoaders = options . importLoaders || 0 ;
19+ const { url, import : importOpt , sourceMap, importLoaders } = Object . assign (
20+ { } ,
21+ { url : true , import : true , sourceMap : false , importLoaders : 0 } ,
22+ loaderUtils . getOptions ( this ) || { }
23+ ) ;
2124
2225 if ( sourceMap && map ) {
2326 if ( typeof map === "string" ) {
@@ -115,11 +118,8 @@ module.exports = function(content, map, meta) {
115118
116119 if ( result . messages && result . messages . length > 0 ) {
117120 result . messages
118- . filter (
119- message =>
120- message . type === "modify-code" ? message : false
121- )
122- . forEach ( ( message ) => {
121+ . filter ( message => ( message . type === "modify-code" ? message : false ) )
122+ . forEach ( message => {
123123 try {
124124 newContentObj = message . modifyCode ( this , newContentObj ) ;
125125 } catch ( err ) {
0 commit comments