mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
add tests for font preload
This commit is contained in:
parent
5eeca5a41b
commit
5c2f4715e6
12
test/fixtures/with-config/assets/app.css
vendored
12
test/fixtures/with-config/assets/app.css
vendored
@ -1,3 +1,15 @@
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Roboto'), local('Roboto-Regular'), url(../assets/roboto.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto';
|
||||
}
|
||||
|
||||
.global-css-selector {
|
||||
color: red;
|
||||
}
|
||||
|
BIN
test/fixtures/with-config/assets/roboto.woff2
vendored
Normal file
BIN
test/fixtures/with-config/assets/roboto.woff2
vendored
Normal file
Binary file not shown.
7
test/fixtures/with-config/nuxt.config.js
vendored
7
test/fixtures/with-config/nuxt.config.js
vendored
@ -27,7 +27,7 @@ module.exports = {
|
||||
string: 'Nuxt.js'
|
||||
},
|
||||
build: {
|
||||
extractCSS: true,
|
||||
// extractCSS: true,
|
||||
publicPath: '/orion/',
|
||||
analyze: {
|
||||
analyzerMode: 'disabled',
|
||||
@ -46,6 +46,11 @@ module.exports = {
|
||||
http2: {
|
||||
push: true
|
||||
},
|
||||
bundleRenderer: {
|
||||
shouldPreload: (file, type) => {
|
||||
return ['script', 'style', 'font'].includes(type)
|
||||
}
|
||||
},
|
||||
static: {
|
||||
maxAge: '1y'
|
||||
}
|
||||
|
@ -26,9 +26,13 @@ test('/', async t => {
|
||||
})
|
||||
|
||||
test('/ (global styles inlined)', async t => {
|
||||
// const { html } = await nuxt.renderRoute('/')
|
||||
// t.true(html.includes('.global-css-selector'))
|
||||
t.pass()
|
||||
const { html } = await nuxt.renderRoute('/')
|
||||
t.true(html.includes('.global-css-selector'))
|
||||
})
|
||||
|
||||
test('/ (preload fonts)', async t => {
|
||||
const { html } = await nuxt.renderRoute('/')
|
||||
t.true(html.includes('<link rel="preload" href="/test/orion/fonts/roboto.7cf5d7c.woff2" as="font" type="font/woff2" crossorigin'))
|
||||
})
|
||||
|
||||
test('/ (custom app.html)', async t => {
|
||||
@ -87,7 +91,7 @@ test('/test/about-bis (added with extendRoutes)', async t => {
|
||||
|
||||
test('Check stats.json generated by build.analyze', t => {
|
||||
const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json'))
|
||||
t.is(stats.assets.length, 28)
|
||||
t.is(stats.assets.length, 27)
|
||||
})
|
||||
|
||||
test('Check /test/test.txt with custom serve-static options', async t => {
|
||||
|
Loading…
Reference in New Issue
Block a user