Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental feature changes (for CSS) #21462

Merged
merged 52 commits into from Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
edabb95
Updating native-url version
janicklas-ralph Apr 4, 2020
c147099
Bump version
janicklas-ralph Apr 5, 2020
63b04ca
Merge branch 'canary' of github.com:zeit/next.js into canary
janicklas-ralph Apr 16, 2020
df52e5e
Merge branch 'canary' of github.com:zeit/next.js into canary
janicklas-ralph May 4, 2020
1baaf87
Merge branch 'canary' of github.com:zeit/next.js into canary
janicklas-ralph Aug 14, 2020
68bff2a
Merge branch 'canary' of github.com:zeit/next.js into canary
janicklas-ralph Aug 24, 2020
0aa63a4
Setup CSS optimization. Experimental inlining critical css
janicklas-ralph Aug 25, 2020
f812418
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Aug 25, 2020
42686d4
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Sep 29, 2020
90f475d
Critical CSS setup
janicklas-ralph Sep 29, 2020
6382ff2
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Sep 29, 2020
56ff05e
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 6, 2020
b728cba
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 7, 2020
2074b67
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 9, 2020
0361ac5
Enabling config override for critters. Updating critters
janicklas-ralph Oct 10, 2020
205cf62
Update critical css position
janicklas-ralph Oct 10, 2020
618ef3f
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 10, 2020
3387a7b
Fix lint error
janicklas-ralph Oct 10, 2020
9942ff6
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 12, 2020
648765c
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Oct 15, 2020
fa95198
Update critters version 0.0.6 reduced the install size
janicklas-ralph Oct 15, 2020
3d5c9b3
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 6, 2020
8a8662c
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 10, 2020
95521ee
Removing critters as a dependency
janicklas-ralph Nov 10, 2020
e327729
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 11, 2020
85214fb
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 11, 2020
527dca4
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 11, 2020
dbc456d
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 12, 2020
a367a6f
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 12, 2020
2063de9
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 17, 2020
bf1f16f
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 17, 2020
e92110c
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 17, 2020
19505b6
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 18, 2020
389980d
Fix merging
janicklas-ralph Nov 18, 2020
a1470bc
Adding critter to top level dependency
janicklas-ralph Nov 18, 2020
04aa9d2
Fixing lint
janicklas-ralph Nov 18, 2020
d3054ea
Mark package as external when not used
ijjk Nov 18, 2020
88a8c8e
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 19, 2020
bb55512
Merge branch 'css-optimization' of github.com:janicklas-ralph/next.js…
janicklas-ralph Nov 19, 2020
1aafd1a
Fix failing test case
janicklas-ralph Nov 19, 2020
65de0b5
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 20, 2020
995e1eb
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 20, 2020
1fe3de2
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 21, 2020
456b2fa
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 24, 2020
7b2006f
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 25, 2020
60fde8b
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Nov 30, 2020
060cc55
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Dec 1, 2020
ba6ef1a
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Dec 7, 2020
deb0f3d
Merge branch 'canary' of github.com:zeit/next.js into css-optimization
janicklas-ralph Jan 23, 2021
03ca0c2
Fix bug for serverless. Adding tests
janicklas-ralph Jan 23, 2021
6882f4e
Merge branch 'canary' into css-optimization
kodiakhq[bot] Jan 24, 2021
08082b5
Merge branch 'canary' into css-optimization
Timer Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/export/worker.ts
Expand Up @@ -273,6 +273,7 @@ export default async function exportPage({
optimizeImages,
/// @ts-ignore
optimizeCss,
distDir,
fontManifest: optimizeFonts
? requireFontManifest(distDir, serverless)
: null,
Expand Down
6 changes: 6 additions & 0 deletions test/integration/critical-css/pages/_app.js
@@ -0,0 +1,6 @@
import '../styles/styles.css'

// This default export is required in a new `pages/_app.js` file.
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
9 changes: 9 additions & 0 deletions test/integration/critical-css/pages/index.js
@@ -0,0 +1,9 @@
import styles from '../styles/index.module.css'

export default function Home() {
return (
<div className={styles.hello}>
<p>Hello World</p>
</div>
)
}
15 changes: 15 additions & 0 deletions test/integration/critical-css/styles/index.module.css
@@ -0,0 +1,15 @@
.hello {
font: 15px Helvetica, Arial, sans-serif;
background: #eee;
padding: 100px;
text-align: center;
transition: 100ms ease-in background;
}

.hello:hover {
background: #ccc;
}

.extra-style1 {
background: #000;
}
11 changes: 11 additions & 0 deletions test/integration/critical-css/styles/styles.css
@@ -0,0 +1,11 @@
body {
font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica',
'Arial', sans-serif;
padding: 20px 20px 60px;
max-width: 680px;
margin: 0 auto;
}

.extra-style {
font-size: 200%;
}
67 changes: 67 additions & 0 deletions test/integration/critical-css/test/index.test.js
@@ -0,0 +1,67 @@
/* eslint-env jest */

import { join } from 'path'
import {
killApp,
findPort,
nextStart,
nextBuild,
renderViaHTTP,
} from 'next-test-utils'
import fs from 'fs-extra'

jest.setTimeout(1000 * 60 * 2)

const appDir = join(__dirname, '../')
const nextConfig = join(appDir, 'next.config.js')
let appPort
let app

function runTests() {
it('should inline critical CSS', async () => {
const html = await renderViaHTTP(appPort, '/index')
expect(html).toMatch(
/<link rel="stylesheet" href="\/_next\/static\/css\/.*\.css" .*>/
)
expect(html).toMatch(/body{font-family:SF Pro Text/)
})

it('should not inline non-critical css', async () => {
const html = await renderViaHTTP(appPort, '/index')
expect(html).not.toMatch(/.extra-style/)
})
}

describe('CSS optimization for SSR apps', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { experimental: {optimizeCss: true} }`,
'utf8'
)

if (fs.pathExistsSync(join(appDir, '.next'))) {
await fs.remove(join(appDir, '.next'))
}
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})

describe('CSS optimization for serverless apps', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'serverless', experimental: {optimizeCss: true} }`,
'utf8'
)
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})