Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
cf6bc446
Unverified
Commit
cf6bc446
authored
Feb 17, 2021
by
Janicklas Ralph
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experimental feature - fix optimizeCss flag for serverless deployments (#21790)
parent
1c3ac0e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
12 deletions
+34
-12
index.ts
packages/next/build/index.ts
+9
-0
utils.ts
packages/next/build/utils.ts
+13
-0
index.ts
...ext/build/webpack/loaders/next-serverless-loader/index.ts
+12
-12
No files found.
packages/next/build/index.ts
View file @
cf6bc446
...
...
@@ -80,6 +80,7 @@ import {
PageInfo
,
printCustomRoutes
,
printTreeView
,
getCssFilePaths
,
}
from
'./utils'
import
getBaseWebpackConfig
from
'./webpack-config'
import
{
PagesManifest
}
from
'./webpack/plugins/pages-manifest-plugin'
...
...
@@ -873,6 +874,14 @@ export default async function build(
await
writeBuildId
(
distDir
,
buildId
)
if
(
config
.
experimental
.
optimizeCss
)
{
const
cssFilePaths
=
getCssFilePaths
(
buildManifest
)
requiredServerFiles
.
files
.
push
(
...
cssFilePaths
.
map
((
filePath
)
=>
path
.
join
(
config
.
distDir
,
filePath
))
)
}
await
promises
.
writeFile
(
path
.
join
(
distDir
,
SERVER_FILES_MANIFEST
),
JSON
.
stringify
(
requiredServerFiles
),
...
...
packages/next/build/utils.ts
View file @
cf6bc446
...
...
@@ -956,3 +956,16 @@ export function detectConflictingPaths(
process
.
exit
(
1
)
}
}
export
function
getCssFilePaths
(
buildManifest
:
BuildManifest
):
string
[]
{
const
cssFiles
=
new
Set
<
string
>
()
Object
.
values
(
buildManifest
.
pages
).
forEach
((
files
)
=>
{
files
.
forEach
((
file
)
=>
{
if
(
file
.
endsWith
(
'.css'
))
{
cssFiles
.
add
(
file
)
}
})
})
return
[...
cssFiles
]
}
packages/next/build/webpack/loaders/next-serverless-loader/index.ts
View file @
cf6bc446
...
...
@@ -103,9 +103,9 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
import onError from 'next-plugin-loader?middleware=on-error-server!'
import 'next/dist/next-server/server/node-polyfill-fetch'
import routesManifest from '
${
routesManifest
}
'
import { getApiHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/api-handler'
const apiHandler = getApiHandler({
pageModule: require("
${
absolutePagePath
}
"),
rewrites: routesManifest.rewrites,
...
...
@@ -129,7 +129,7 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
import routesManifest from '
${
routesManifest
}
'
import buildManifest from '
${
buildManifest
}
'
import reactLoadableManifest from '
${
reactLoadableManifest
}
'
${
envLoading
}
${
runtimeConfigImports
}
${
...
...
@@ -137,27 +137,27 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
runtimeConfigSetter
}
import { getPageHandler } from 'next/dist/build/webpack/loaders/next-serverless-loader/page-handler'
const appMod = require('
${
absoluteAppPath
}
')
let App = appMod.default || appMod.then && appMod.then(mod => mod.default);
const compMod = require('
${
absolutePagePath
}
')
const Component = compMod.default || compMod.then && compMod.then(mod => mod.default)
export default Component
export const getStaticProps = compMod['getStaticProp' + 's'] || compMod.then && compMod.then(mod => mod['getStaticProp' + 's'])
export const getStaticPaths = compMod['getStaticPath' + 's'] || compMod.then && compMod.then(mod => mod['getStaticPath' + 's'])
export const getServerSideProps = compMod['getServerSideProp' + 's'] || compMod.then && compMod.then(mod => mod['getServerSideProp' + 's'])
// kept for detecting legacy exports
export const unstable_getStaticParams = compMod['unstable_getStaticParam' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticParam' + 's'])
export const unstable_getStaticProps = compMod['unstable_getStaticProp' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticProp' + 's'])
export const unstable_getStaticPaths = compMod['unstable_getStaticPath' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getStaticPath' + 's'])
export const unstable_getServerProps = compMod['unstable_getServerProp' + 's'] || compMod.then && compMod.then(mod => mod['unstable_getServerProp' + 's'])
export let config = compMod['confi' + 'g'] || (compMod.then && compMod.then(mod => mod['confi' + 'g'])) || {}
export const _app = App
const { renderReqToHTML, render } = getPageHandler({
pageModule: compMod,
pageComponent: Component,
...
...
@@ -171,16 +171,16 @@ const nextServerlessLoader: webpack.loader.Loader = function () {
pageGetStaticProps: getStaticProps,
pageGetStaticPaths: getStaticPaths,
pageGetServerSideProps: getServerSideProps,
assetPrefix: "
${
assetPrefix
}
",
canonicalBase: "
${
canonicalBase
}
",
generateEtags:
${
generateEtags
||
'false'
}
,
poweredByHeader:
${
poweredByHeader
||
'false'
}
,
runtimeConfig,
buildManifest,
reactLoadableManifest,
rewrites: routesManifest.rewrites,
i18n:
${
i18n
||
'undefined'
}
,
page: "
${
page
}
",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment