-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle css-loader file resolving change (#17724)
This is a follow-up to #16973 which adds handling for the breaking change in the latest version of css-loader that causes unresolved file references in `url` or `import` to cause the build to fail. This fixes it by adding our own resolve checking and when it fails disabling the `css-loader`'s handling of it. Fixes: #17701
- Loading branch information
Showing
12 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/next/build/webpack/config/blocks/css/loaders/file-resolve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function cssFileResolve(url: string, _resourcePath: string) { | ||
if (url.startsWith('/')) { | ||
return false | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/integration/css-fixtures/unresolved-css-url/global.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
p { | ||
background-image: url('/vercel.svg'); | ||
} | ||
|
||
p:nth-child(1) { | ||
background-image: url(/vercel.svg); | ||
} | ||
|
||
/* p:nth-child(2) { | ||
background-image: url('./vercel.svg'); | ||
} | ||
p:nth-child(3) { | ||
background-image: url(./vercel.svg); | ||
} */ | ||
|
||
p:nth-child(4) { | ||
background-image: url('./public/vercel.svg'); | ||
} | ||
|
||
p:nth-child(5) { | ||
background-image: url(./public/vercel.svg); | ||
} | ||
|
||
div { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} | ||
|
||
div:nth-child(1) { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} |
31 changes: 31 additions & 0 deletions
31
test/integration/css-fixtures/unresolved-css-url/global.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.p { | ||
background-image: url('/vercel.svg'); | ||
} | ||
|
||
.p:nth-child(1) { | ||
background-image: url(/vercel.svg); | ||
} | ||
|
||
// .p:nth-child(2) { | ||
// background-image: url('./vercel.svg'); | ||
// } | ||
|
||
// .p:nth-child(3) { | ||
// background-image: url(./vercel.svg); | ||
// } | ||
|
||
p:nth-child(4) { | ||
background-image: url('./public/vercel.svg'); | ||
} | ||
|
||
p:nth-child(5) { | ||
background-image: url(./public/vercel.svg); | ||
} | ||
|
||
.div { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} | ||
|
||
.div:nth-child(1) { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} |
6 changes: 6 additions & 0 deletions
6
test/integration/css-fixtures/unresolved-css-url/pages/_app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import '../global.css' | ||
import '../global.scss' | ||
|
||
export default function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
} |
5 changes: 5 additions & 0 deletions
5
test/integration/css-fixtures/unresolved-css-url/pages/another.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import styles from './another.module.scss' | ||
|
||
export default function Page() { | ||
return <p className={styles.first}>Hello from index</p> | ||
} |
31 changes: 31 additions & 0 deletions
31
test/integration/css-fixtures/unresolved-css-url/pages/another.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.first { | ||
background-image: url('/vercel.svg'); | ||
} | ||
|
||
.first:nth-child(1) { | ||
background-image: url(/vercel.svg); | ||
} | ||
|
||
// .first:nth-child(2) { | ||
// background-image: url('./vercel.svg'); | ||
// } | ||
|
||
// .first:nth-child(3) { | ||
// background-image: url(./vercel.svg); | ||
// } | ||
|
||
.first:nth-child(4) { | ||
background-image: url('../public/vercel.svg'); | ||
} | ||
|
||
.first:nth-child(5) { | ||
background-image: url(../public/vercel.svg); | ||
} | ||
|
||
.another { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} | ||
|
||
.another:nth-child(1) { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} |
5 changes: 5 additions & 0 deletions
5
test/integration/css-fixtures/unresolved-css-url/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import styles from './index.module.css' | ||
|
||
export default function Page() { | ||
return <p className={styles.first}>Hello from index</p> | ||
} |
31 changes: 31 additions & 0 deletions
31
test/integration/css-fixtures/unresolved-css-url/pages/index.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.first { | ||
background-image: url('/vercel.svg'); | ||
} | ||
|
||
.first:nth-child(1) { | ||
background-image: url(/vercel.svg); | ||
} | ||
|
||
/* .first:nth-child(2) { | ||
background-image: url('./vercel.svg'); | ||
} | ||
.first:nth-child(3) { | ||
background-image: url(./vercel.svg); | ||
} */ | ||
|
||
.first:nth-child(4) { | ||
background-image: url('../public/vercel.svg'); | ||
} | ||
|
||
.first:nth-child(5) { | ||
background-image: url(../public/vercel.svg); | ||
} | ||
|
||
.another { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} | ||
|
||
.another:nth-child(1) { | ||
background-image: url('https://vercel.com/vercel.svg'); | ||
} |
1 change: 1 addition & 0 deletions
1
test/integration/css-fixtures/unresolved-css-url/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters