@@ -220,3 +220,69 @@ test('should output unix paths', async (t) => {
220220 'some/dir/main.js' : 'some/dir/main.js'
221221 } ) ;
222222} ) ;
223+
224+ test ( 'should handle publicPath set to auto' , async ( t ) => {
225+ const config = {
226+ context : __dirname ,
227+ entry : {
228+ one : '../fixtures/file.js'
229+ } ,
230+ output : {
231+ filename : `[name].${ hashLiteral } .js` ,
232+ path : join ( outputPath , 'public-auto' ) ,
233+ publicPath : 'auto'
234+ }
235+ } ;
236+ const { manifest, stats } = await compile ( config , t ) ;
237+
238+ // When publicPath is 'auto', it should not be added to the asset paths
239+ // The manifest should contain relative paths without any publicPath prefix
240+ t . deepEqual ( manifest , {
241+ 'one.js' : `one.${ stats . hash } .js`
242+ } ) ;
243+ } ) ;
244+
245+ test ( 'should handle publicPath set to auto with basePath' , async ( t ) => {
246+ const config = {
247+ context : __dirname ,
248+ entry : {
249+ one : '../fixtures/file.js'
250+ } ,
251+ output : {
252+ filename : `[name].${ hashLiteral } .js` ,
253+ path : join ( outputPath , 'public-auto-base' ) ,
254+ publicPath : 'auto'
255+ }
256+ } ;
257+ const { manifest, stats } = await compile ( config , t , {
258+ basePath : '/app/'
259+ } ) ;
260+
261+ // When publicPath is 'auto' but basePath is set, basePath should still work
262+ // but publicPath should not be added to the asset paths
263+ t . deepEqual ( manifest , {
264+ '/app/one.js' : `one.${ stats . hash } .js`
265+ } ) ;
266+ } ) ;
267+
268+ test ( 'should override auto publicPath when plugin publicPath is explicitly set' , async ( t ) => {
269+ const config = {
270+ context : __dirname ,
271+ entry : {
272+ one : '../fixtures/file.js'
273+ } ,
274+ output : {
275+ filename : `[name].${ hashLiteral } .js` ,
276+ path : join ( outputPath , 'public-auto-override' ) ,
277+ publicPath : 'auto'
278+ }
279+ } ;
280+ const { manifest, stats } = await compile ( config , t , {
281+ publicPath : '/custom/'
282+ } ) ;
283+
284+ // When plugin publicPath is explicitly set, it should override the webpack auto setting
285+ t . deepEqual ( manifest , {
286+ 'one.js' : `/custom/one.${ stats . hash } .js`
287+ } ) ;
288+ } ) ;
0 commit comments