File tree 11 files changed +79
-7
lines changed
test/cases/publicpath-function-2
11 files changed +79
-7
lines changed Original file line number Diff line number Diff line change @@ -204,13 +204,22 @@ export function pitch(request) {
204
204
return ;
205
205
}
206
206
207
- const isAbsolutePublicPath = / ^ [ a - z A - Z ] [ a - z A - Z \d + \- . ] * ?: / . test ( publicPath ) ;
208
- const publicPathForExtract = isAbsolutePublicPath
209
- ? publicPath
210
- : `${ ABSOLUTE_PUBLIC_PATH } ${ publicPath . replace (
211
- / \. / g,
212
- SINGLE_DOT_PATH_SEGMENT
213
- ) } `;
207
+ let publicPathForExtract ;
208
+
209
+ if ( typeof publicPath === "string" ) {
210
+ const isAbsolutePublicPath = / ^ [ a - z A - Z ] [ a - z A - Z \d + \- . ] * ?: / . test (
211
+ publicPath
212
+ ) ;
213
+
214
+ publicPathForExtract = isAbsolutePublicPath
215
+ ? publicPath
216
+ : `${ ABSOLUTE_PUBLIC_PATH } ${ publicPath . replace (
217
+ / \. / g,
218
+ SINGLE_DOT_PATH_SEGMENT
219
+ ) } `;
220
+ } else {
221
+ publicPathForExtract = publicPath ;
222
+ }
214
223
215
224
this . importModule (
216
225
`${ this . resourcePath } .webpack[javascript/auto]!=!!!${ request } ` ,
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : green;
3
+ background-image : url (http://example.com/XXXX/c9e192c015437a21dea1.svg);
4
+ }
5
+
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : red;
3
+ background-image : url (http://example.com/XXXX/c9e192c015437a21dea1.svg);
4
+ }
5
+
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : green;
3
+ background-image : url (http://example.com/4d869bb95ecdf3f870fb/c9e192c015437a21dea1.svg);
4
+ }
5
+
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : red;
3
+ background-image : url (http://example.com/ca6e489a6807af3e778c/c9e192c015437a21dea1.svg);
4
+ }
5
+
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : green;
3
+ background-image : url (../ ../ react.svg);
4
+ }
Original file line number Diff line number Diff line change
1
+ body {
2
+ background : red;
3
+ background-image : url (../ react.svg);
4
+ }
Original file line number Diff line number Diff line change
1
+ import Self from "../../../src" ;
2
+
3
+ module . exports = {
4
+ entry : {
5
+ // Specific CSS entry point, with output to a nested folder
6
+ "nested/style" : "./nested/style.css" ,
7
+ // Note that relative nesting of output is the same as that of the input
8
+ "nested/again/style" : "./nested/again/style.css" ,
9
+ } ,
10
+ output : {
11
+ // Compute publicPath relative to the CSS output
12
+ publicPath : ( pathData ) => `http://example.com/${ pathData . hash } /` ,
13
+ } ,
14
+ module : {
15
+ rules : [
16
+ {
17
+ test : / \. c s s $ / ,
18
+ use : [
19
+ {
20
+ loader : Self . loader ,
21
+ } ,
22
+ "css-loader" ,
23
+ ] ,
24
+ } ,
25
+ ] ,
26
+ } ,
27
+ plugins : [
28
+ new Self ( {
29
+ filename : "[name].css" ,
30
+ } ) ,
31
+ ] ,
32
+ } ;
You can’t perform that action at this time.
0 commit comments