@@ -46,6 +46,30 @@ describe('fallback option', () => {
4646 expect ( source ) . toMatchSnapshot ( ) ;
4747 } ) ;
4848
49+ it ( '{String} require.resolve' , async ( ) => {
50+ const config = {
51+ rules : [
52+ {
53+ test : / \. p n g $ / ,
54+ use : {
55+ loader : path . join ( __dirname , '../src' ) ,
56+ options : {
57+ limit : Number . MIN_SAFE_INTEGER ,
58+ name : '[name].[hash].[ext]' ,
59+ unknown : 'value' ,
60+ fallback : require . resolve ( './fixtures/x-custom-loader' ) ,
61+ } ,
62+ } ,
63+ } ,
64+ ] ,
65+ } ;
66+
67+ const stats = await webpack ( 'fixture.js' , config ) ;
68+ const [ { source } ] = stats . toJson ( ) . modules ;
69+
70+ expect ( source ) . toMatchSnapshot ( ) ;
71+ } ) ;
72+
4973 it ( '{String} (with query)' , async ( ) => {
5074 const config = {
5175 rules : [
@@ -73,6 +97,32 @@ describe('fallback option', () => {
7397 expect ( source ) . toMatchSnapshot ( ) ;
7498 } ) ;
7599
100+ it ( '{String} (with query) require.resolve' , async ( ) => {
101+ const config = {
102+ rules : [
103+ {
104+ test : / \. p n g $ / ,
105+ use : {
106+ loader : path . join ( __dirname , '../src' ) ,
107+ options : {
108+ limit : Number . MIN_SAFE_INTEGER ,
109+ name : '[name].[hash].[ext]' ,
110+ unknown : 'value' ,
111+ fallback : `${ require . resolve (
112+ './fixtures/x-custom-loader'
113+ ) } ?name=fallback-[hash].[ext]&unknown=fallback-value`,
114+ } ,
115+ } ,
116+ } ,
117+ ] ,
118+ } ;
119+
120+ const stats = await webpack ( 'fixture.js' , config ) ;
121+ const [ { source } ] = stats . toJson ( ) . modules ;
122+
123+ expect ( source ) . toMatchSnapshot ( ) ;
124+ } ) ;
125+
76126 it ( '{Object}' , async ( ) => {
77127 const config = {
78128 rules : [
@@ -102,4 +152,34 @@ describe('fallback option', () => {
102152
103153 expect ( source ) . toMatchSnapshot ( ) ;
104154 } ) ;
155+
156+ it ( '{Object} require.resolve' , async ( ) => {
157+ const config = {
158+ rules : [
159+ {
160+ test : / \. p n g $ / ,
161+ use : {
162+ loader : path . join ( __dirname , '../src' ) ,
163+ options : {
164+ limit : Number . MIN_SAFE_INTEGER ,
165+ name : '[name].[hash].[ext]' ,
166+ unknown : 'value' ,
167+ fallback : {
168+ loader : require . resolve ( './fixtures/x-custom-loader' ) ,
169+ options : {
170+ name : 'fallback-[hash].[ext]' ,
171+ unknown : 'fallback-other-value' ,
172+ } ,
173+ } ,
174+ } ,
175+ } ,
176+ } ,
177+ ] ,
178+ } ;
179+
180+ const stats = await webpack ( 'fixture.js' , config ) ;
181+ const [ { source } ] = stats . toJson ( ) . modules ;
182+
183+ expect ( source ) . toMatchSnapshot ( ) ;
184+ } ) ;
105185} ) ;
0 commit comments