@@ -8,21 +8,28 @@ module.exports = function (source) {
8
8
const options = this . getOptions ( ) ;
9
9
const force = options . force || false ;
10
10
11
- const allLoadersButThisOne = this . loaders . filter ( function ( loader ) {
12
- return loader . normal !== module . exports ;
13
- } ) ;
11
+ const allLoadersButThisOne = this . loaders . filter ( ( loader ) => loader . normal !== module . exports ) ;
12
+
14
13
// This loader shouldn't kick in if there is any other loader (unless it's explicitly enforced)
15
14
if ( allLoadersButThisOne . length > 0 && ! force ) {
16
15
return source ;
17
16
}
17
+
18
+ // Allow only one html-webpack-plugin loader to allow loader options in the webpack config
19
+ const htmlWebpackPluginLoaders = this . loaders . filter ( ( loader ) => loader . normal === module . exports ) ;
20
+ const lastHtmlWebpackPluginLoader = htmlWebpackPluginLoaders [ htmlWebpackPluginLoaders . length - 1 ] ;
21
+ if ( this . loaders [ this . loaderIndex ] !== lastHtmlWebpackPluginLoader ) {
22
+ return source ;
23
+ }
24
+
18
25
// Skip .js files (unless it's explicitly enforced)
19
26
if ( / \. j s $ / . test ( this . resourcePath ) && ! force ) {
20
27
return source ;
21
28
}
22
29
23
30
// The following part renders the template with lodash as a minimalistic loader
24
31
//
25
- const template = _ . template ( source , _ . defaults ( options , { interpolate : / < % = ( [ \s \S ] + ?) % > / g, variable : 'data' } ) ) ;
32
+ const template = _ . template ( source , { interpolate : / < % = ( [ \s \S ] + ?) % > / g, variable : 'data' , ... options } ) ;
26
33
// Use __non_webpack_require__ to enforce using the native nodejs require
27
34
// during template execution
28
35
return 'var _ = __non_webpack_require__(' + JSON . stringify ( require . resolve ( 'lodash' ) ) + ');' +
0 commit comments