Unverified Commit 04e1e01f authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

test, fix and document all possible import types for URL imports (#30165)

resolve absolute URLs in CSS when using urlImports
remove `[path]` from static static image output path
replace file-loader with asset module, remove file-loader
parent 1e82a3f2
......@@ -19,7 +19,7 @@ module.exports = {
Then, you can import modules directly from URLs:
```js
import { a, b, c } from 'https://example.com/modules/'
import { a, b, c } from 'https://example.com/modules/some/module.js'
```
URL Imports can be used everywhere normal package imports can be used.
......@@ -35,3 +35,53 @@ This directory is intended to be committed to Git and should **not be included**
Typically, no network requests are needed and any outdated lockfile will cause the build to fail.
One exception is resources that respond with `Cache-Control: no-cache`.
These resources will have a `no-cache` entry in the lockfile and will always be fetched from the network on each build.
## Examples
From skypack CDN:
```js
import confetti from 'https://cdn.skypack.dev/canvas-confetti'
import { useEffect } from 'react'
export default () => {
useEffect(() => {
confetti()
})
return <p>Hello</p>
}
```
Static image imports:
```js
import Image from 'next/image'
import logo from 'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png'
export default () => (
<div>
<Image src={logo} placeholder="blur" />
</div>
)
```
URLs in CSS:
```css
.className {
background: url('https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png');
}
```
Asset imports:
```js
import Image from 'next/image'
const logo = new URL(
'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png',
import.meta.url
)
export default () => <div>{logo.pathname}</div>
```
......@@ -1502,7 +1502,7 @@ export default async function getBaseWebpackConfig(
sassOptions: config.sassOptions,
productionBrowserSourceMaps: config.productionBrowserSourceMaps,
future: config.future,
isCraCompat: config.experimental.craCompat,
experimental: config.experimental,
})
// @ts-ignore Cache exists
......
......@@ -260,7 +260,7 @@ export const css = curry(async function css(
include: { and: [/node_modules/] },
// Global CSS is only supported in the user's application, not in
// node_modules.
issuer: ctx.isCraCompat
issuer: ctx.experimental.craCompat
? undefined
: {
and: [ctx.rootDirectory],
......@@ -309,7 +309,7 @@ export const css = curry(async function css(
}
// Throw an error for Global CSS used inside of `node_modules`
if (!ctx.isCraCompat) {
if (!ctx.experimental.craCompat) {
fns.push(
loader({
oneOf: [
......@@ -361,15 +361,9 @@ export const css = curry(async function css(
/\.json$/,
/\.webpack\[[^\]]+\]$/,
],
use: {
// `file-loader` always emits a URL reference, where `url-loader`
// might inline the asset as a data URI
loader: require.resolve('next/dist/compiled/file-loader'),
options: {
// Hash the file for immutable cacheability
name: 'static/media/[name].[hash].[ext]',
},
},
// `asset/resource` always emits a URL reference, where `asset`
// might inline the asset as a data URI
type: 'asset/resource',
},
],
})
......
export function cssFileResolve(url: string, _resourcePath: string) {
export function cssFileResolve(
url: string,
_resourcePath: string,
urlImports: any
) {
if (url.startsWith('/')) {
return false
}
if (!urlImports && /^[a-z][a-z0-9+.-]*:/i.test(url)) {
return false
}
return true
}
......@@ -30,9 +30,10 @@ export function getGlobalCssLoader(
importLoaders: 1 + preProcessors.length,
// Next.js controls CSS Modules eligibility:
modules: false,
url: cssFileResolve,
url: (url: string, resourcePath: string) =>
cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url: string, _: any, resourcePath: string) =>
cssFileResolve(url, resourcePath),
cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
},
})
......
......@@ -31,9 +31,10 @@ export function getCssModuleLoader(
importLoaders: 1 + preProcessors.length,
// Use CJS mode for backwards compatibility:
esModule: false,
url: cssFileResolve,
url: (url: string, resourcePath: string) =>
cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url: string, _: any, resourcePath: string) =>
cssFileResolve(url, resourcePath),
cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: 'asIs',
......
......@@ -16,7 +16,7 @@ export async function build(
sassOptions,
productionBrowserSourceMaps,
future,
isCraCompat,
experimental,
}: {
rootDirectory: string
customAppFile: RegExp
......@@ -26,7 +26,7 @@ export async function build(
sassOptions: any
productionBrowserSourceMaps: boolean
future: NextConfigComplete['future']
isCraCompat?: boolean
experimental: NextConfigComplete['experimental']
}
): Promise<webpack.Configuration> {
const ctx: ConfigurationContext = {
......@@ -44,7 +44,7 @@ export async function build(
sassOptions,
productionBrowserSourceMaps,
future,
isCraCompat,
experimental,
}
const fn = pipe(base(ctx), css(ctx), images(ctx))
......
......@@ -17,8 +17,7 @@ export type ConfigurationContext = {
productionBrowserSourceMaps: boolean
future: NextConfigComplete['future']
isCraCompat?: boolean
experimental: NextConfigComplete['experimental']
}
export type ConfigurationFn = (
......
......@@ -62,6 +62,10 @@ function requestify(url, rootContext) {
return fileURLToPath(url)
}
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return url
}
return url.charAt(0) === '/'
? urlToRequest(url, rootContext)
: urlToRequest(url)
......@@ -602,8 +606,8 @@ function isUrlRequestable(url) {
}
// Absolute URLs
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !matchNativeWin32Path.test(url)) {
return false
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return true
}
// `#` URLs
......
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module.exports=(()=>{"use strict";var e={764:e=>{e.exports=JSON.parse('{"additionalProperties":true,"properties":{"name":{"description":"The filename template for the target file(s) (https://github.com/webpack-contrib/file-loader#name).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"outputPath":{"description":"A filesystem path where the target file(s) will be placed (https://github.com/webpack-contrib/file-loader#outputpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"publicPath":{"description":"A custom public path for the target file(s) (https://github.com/webpack-contrib/file-loader#publicpath).","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"postTransformPublicPath":{"description":"A custom transformation function for post-processing the publicPath (https://github.com/webpack-contrib/file-loader#posttransformpublicpath).","instanceof":"Function"},"context":{"description":"A custom file context (https://github.com/webpack-contrib/file-loader#context).","type":"string"},"emitFile":{"description":"Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile).","type":"boolean"},"regExp":{"description":"A Regular Expression to one or many parts of the target file path. The capture groups can be reused in the name property using [N] placeholder (https://github.com/webpack-contrib/file-loader#regexp).","anyOf":[{"type":"string"},{"instanceof":"RegExp"}]},"esModule":{"description":"By default, file-loader generates JS modules that use the ES modules syntax.","type":"boolean"}},"type":"object"}')},467:(e,t,i)=>{const r=i(206);e.exports=r.default;e.exports.raw=r.raw},206:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t.default=loader;t.raw=void 0;var r=_interopRequireDefault(i(622));var o=_interopRequireDefault(i(443));var a=_interopRequireDefault(i(99));var n=_interopRequireDefault(i(764));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function loader(e){const t=o.default.getOptions(this);(0,a.default)(n.default,t,{name:"File Loader",baseDataPath:"options"});const i=t.context||this.rootContext;const s=o.default.interpolateName(this,t.name||"[contenthash].[ext]",{context:i,content:e,regExp:t.regExp});let p=s;if(t.outputPath){if(typeof t.outputPath==="function"){p=t.outputPath(s,this.resourcePath,i)}else{p=r.default.posix.join(t.outputPath,s)}}let u=`__webpack_public_path__ + ${JSON.stringify(p)}`;if(t.publicPath){if(typeof t.publicPath==="function"){u=t.publicPath(s,this.resourcePath,i)}else{u=`${t.publicPath.endsWith("/")?t.publicPath:`${t.publicPath}/`}${s}`}u=JSON.stringify(u)}if(t.postTransformPublicPath){u=t.postTransformPublicPath(u)}if(typeof t.emitFile==="undefined"||t.emitFile){this.emitFile(p,e)}const l=typeof t.esModule!=="undefined"?t.esModule:true;return`${l?"export default":"module.exports ="} ${u};`}const s=true;t.raw=s},443:e=>{e.exports=require("next/dist/compiled/loader-utils")},99:e=>{e.exports=require("next/dist/compiled/schema-utils2")},622:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(i){if(t[i]){return t[i].exports}var r=t[i]={exports:{}};var o=true;try{e[i](r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete t[i]}return r.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(467)})();
\ No newline at end of file
{"name":"file-loader","main":"cjs.js","author":"Tobias Koppers @sokra","license":"MIT"}
......@@ -207,7 +207,6 @@
"debug": "4.1.1",
"devalue": "2.0.1",
"escape-string-regexp": "2.0.0",
"file-loader": "6.0.0",
"find-cache-dir": "3.3.1",
"find-up": "4.1.0",
"formdata-node": "4.3.0",
......
......@@ -248,20 +248,7 @@ export async function ncc_escape_string_regexp(task, opts) {
.ncc({ packageName: 'escape-string-regexp', externals })
.target('compiled/escape-string-regexp')
}
// eslint-disable-next-line camelcase
externals['file-loader'] = 'next/dist/compiled/file-loader'
export async function ncc_file_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('file-loader')))
.ncc({
packageName: 'file-loader',
externals: {
...externals,
'schema-utils': externals['schema-utils2'],
},
})
.target('compiled/file-loader')
}
// eslint-disable-next-line camelcase
externals['find-cache-dir'] = 'next/dist/compiled/find-cache-dir'
export async function ncc_find_cache_dir(task, opts) {
......@@ -906,7 +893,6 @@ export async function ncc(task, opts) {
'ncc_debug',
'ncc_devalue',
'ncc_escape_string_regexp',
'ncc_file_loader',
'ncc_find_cache_dir',
'ncc_find_up',
'ncc_fresh',
......
......@@ -569,6 +569,7 @@ declare module 'webpack4' {
| 'javascript/esm'
| 'json'
| 'webassembly/experimental'
| 'asset/resource'
/**
* Match the resource path of the module
*/
......
......@@ -699,7 +699,7 @@ describe('CSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -707,7 +707,7 @@ describe('CSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......@@ -745,7 +745,7 @@ describe('CSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -753,7 +753,7 @@ describe('CSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......@@ -791,7 +791,7 @@ describe('CSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -799,7 +799,7 @@ describe('CSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......
......@@ -638,7 +638,7 @@ describe('SCSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -646,7 +646,7 @@ describe('SCSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......@@ -684,7 +684,7 @@ describe('SCSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -692,7 +692,7 @@ describe('SCSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......@@ -730,7 +730,7 @@ describe('SCSS Support', () => {
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatch(
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-z0-9]{32}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-z0-9]{32}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-z0-9]{32}\.svg\);color:blue\}$/
/^\.red-text\{color:red;background-image:url\(\/foo\/_next\/static\/media\/dark\.[a-f0-9]{8}\.svg\) url\(\/foo\/_next\/static\/media\/dark2\.[a-f0-9]{8}\.svg\)\}\.blue-text\{color:orange;font-weight:bolder;background-image:url\(\/foo\/_next\/static\/media\/light\.[a-f0-9]{8}\.svg\);color:blue\}$/
)
const mediaFiles = await readdir(mediaFolder)
......@@ -738,7 +738,7 @@ describe('SCSS Support', () => {
expect(
mediaFiles
.map((fileName) =>
/^(.+?)\..{32}\.(.+?)$/.exec(fileName).slice(1).join('.')
/^(.+?)\..{8}\.(.+?)$/.exec(fileName).slice(1).join('.')
)
.sort()
).toMatchInlineSnapshot(`
......
module.exports = {
experimental: {
urlImports: ['http://localhost:12345/'],
urlImports: [
'http://localhost:12345/',
'https://github.com/vercel/next.js/raw/canary/',
],
},
}
import styles from './css.module.css'
export default () => <div className={styles.main} id="static-css"></div>
.main {
background: url('https://github.com/vercel/next.js/raw/canary/test/integration/url/public/vercel.png');
background-size: contain;
width: 300px;
height: 300px;
}
import Image from 'next/image'
import logo from 'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png'
export default () => (
<div>
<Image src={logo} placeholder="blur" id="static-image" />
</div>
)
import value from 'http://localhost:12345/value1.js'
const url = new URL(
'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png?_=ssg',
import.meta.url
)
export async function getStaticProps() {
return {
props: {
value,
url: url.pathname,
},
}
}
export default function Index({ value: staticValue }) {
export default function Index({ value: staticValue, url: staticUrl }) {
return (
<div>
Hello {staticValue}+{value}
Hello {staticValue}+{value}+{staticUrl}+{url.pathname}
</div>
)
}
import value from 'http://localhost:12345/value2.js'
const url = new URL(
'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png?_=ssr',
import.meta.url
)
export function getServerSideProps() {
return {
props: {
value,
url: url.pathname,
},
}
}
export default function Index({ value: serverValue }) {
export default function Index({ value: serverValue, url: serverUrl }) {
return (
<div>
Hello {serverValue}+{value}
Hello {serverValue}+{value}+{serverUrl}+{url.pathname}
</div>
)
}
import value from 'http://localhost:12345/value3.js'
const url = new URL(
'https://github.com/vercel/next.js/raw/canary/test/integration/production/public/vercel.png?_=static',
import.meta.url
)
export default function Index(props) {
return (
<div>
Hello {value}+{value}
Hello {value}+{value}+{url.pathname}+{url.pathname}
</div>
)
}
......@@ -55,7 +55,8 @@ describe(`Handle url imports`, () => {
afterAll(async () => {
await killApp(app)
})
const expectedServer = /Hello <!-- -->42<!-- -->\+<!-- -->42/
const expectedServer =
/Hello <!-- -->42<!-- -->\+<!-- -->42<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png/
const expectedClient = new RegExp(
expectedServer.source.replace(/<!-- -->/g, '')
)
......@@ -77,6 +78,37 @@ describe(`Handle url imports`, () => {
})
}
it(`should render a static url image import`, async () => {
let browser
try {
browser = await webdriver(appPort, '/image')
await browser.waitForElementByCss('#static-image')
await check(
() => browser.elementByCss('#static-image').getAttribute('src'),
/^\/_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fvercel\.[0-9a-f]{8}\.png&/
)
} finally {
await browser.close()
}
})
it(`should allow url import in css`, async () => {
let browser
try {
browser = await webdriver(appPort, '/css')
await browser.waitForElementByCss('#static-css')
await check(
() =>
browser
.elementByCss('#static-css')
.getComputedCss('background-image'),
/^url\("http:\/\/localhost:\d+\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png"\)$/
)
} finally {
await browser.close()
}
})
it('should respond on value api', async () => {
const data = await fetchViaHTTP(appPort, '/api/value').then(
(res) => res.ok && res.json()
......
......@@ -9512,13 +9512,6 @@ file-entry-cache@^6.0.1:
dependencies:
flat-cache "^3.0.4"
file-loader@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.0.0.tgz#97bbfaab7a2460c07bcbd72d3a6922407f67649f"
dependencies:
loader-utils "^2.0.0"
schema-utils "^2.6.5"
file-name@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/file-name/-/file-name-0.1.0.tgz#12b122f120f9c34dbc176c1ab81a548aced6def7"
......@@ -17354,8 +17347,7 @@ scheduler@^0.20.2:
loose-envify "^1.1.0"
object-assign "^4.1.1"
"schema-utils2@npm:schema-utils@2.7.1", schema-utils@^2.6.5:
name schema-utils2
"schema-utils2@npm:schema-utils@2.7.1":
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment