@@ -4,7 +4,7 @@ const SVGCompiler = require('svg-baker');
44
55const { NAMESPACE } = require ( './config' ) ;
66const configure = require ( './configurator' ) ;
7- const utils = require ( './utils' ) ;
7+ const { getMatchedRules , getLoadersRules } = require ( './utils' ) ;
88const Exceptions = require ( './exceptions' ) ;
99
1010let svgCompiler = new SVGCompiler ( ) ;
@@ -21,6 +21,16 @@ module.exports = function loader(content) {
2121 const compiler = loaderContext . _compiler ;
2222 const isChildCompiler = compiler . isChild ( ) ;
2323 const parentCompiler = isChildCompiler ? compiler . parentCompilation . compiler : null ;
24+ const issuer = loaderContext . _module && loaderContext . _module . issuer ;
25+ const matchedRules = getMatchedRules ( resource , getLoadersRules ( compiler ) , issuer ) ;
26+
27+ if ( matchedRules . length > 1 && ! compiler . isChild ( ) ) {
28+ this . emitWarning ( new Exceptions . SeveralRulesAppliedException ( resource , matchedRules ) ) ;
29+ }
30+
31+ if ( ! content . includes ( '<svg' ) ) {
32+ throw new Exceptions . InvalidSvg ( content , matchedRules ) ;
33+ }
2434
2535 /**
2636 * @type {SVGSpriteLoaderConfig }
@@ -53,12 +63,6 @@ module.exports = function loader(content) {
5363 throw new Exceptions . InvalidRuntimeException ( e . message ) ;
5464 }
5565
56- const issuer = loaderContext . _module && loaderContext . _module . issuer ;
57- const matchedRules = utils . getMatchedRules ( resource , utils . getLoadersRules ( compiler ) , issuer ) ;
58- if ( matchedRules . length > 1 && ! compiler . isChild ( ) ) {
59- this . emitWarning ( new Exceptions . SeveralRulesAppliedException ( resource , matchedRules ) ) ;
60- }
61-
6266 const idPattern = config . symbolId + ( resourceQuery ? `--${ urlSlug ( resourceQuery ) } ` : '' ) ;
6367 const id = interpolateName ( loaderContext , idPattern , {
6468 content,
0 commit comments