Skip to content

fix: include css files in handler functions #1463

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

Merged
merged 3 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demos/default/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module.exports = {
includePaths: [path.join(__dirname, 'styles-sass-test')],
},
experimental: {
optimizeCss: true,
images: {
remotePatterns: [
{
Expand Down
1 change: 1 addition & 0 deletions demos/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"critters": "^0.0.16",
"husky": "^7.0.4",
"if-env": "^1.0.4",
"npm-run-all": "^4.1.5",
Expand Down
131 changes: 129 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion plugin/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const resolveModuleRoot = (moduleName) => {

const DEFAULT_EXCLUDED_MODULES = ['sharp', 'electron']

export const configureHandlerFunctions = ({ netlifyConfig, publish, ignore = [] }) => {
export const configureHandlerFunctions = async ({ netlifyConfig, publish, ignore = [] }) => {
const config = await getRequiredServerFiles(publish)
const files = config.files || []
const cssFilesToInclude = files.filter((f) => f.startsWith(`${publish}/static/css/`))

/* eslint-disable no-underscore-dangle */
netlifyConfig.functions._ipx ||= {}
netlifyConfig.functions._ipx.node_bundler = 'nft'
Expand All @@ -102,6 +106,7 @@ export const configureHandlerFunctions = ({ netlifyConfig, publish, ignore = []
`${publish}/BUILD_ID`,
`${publish}/static/chunks/webpack-middleware*.js`,
`!${publish}/server/**/*.js.nft.json`,
...cssFilesToInclude,
...ignore.map((path) => `!${slash(path)}`),
)

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const plugin: NetlifyPlugin = {

const buildId = readFileSync(join(publish, 'BUILD_ID'), 'utf8').trim()

configureHandlerFunctions({ netlifyConfig, ignore, publish: relative(process.cwd(), publish) })
await configureHandlerFunctions({ netlifyConfig, ignore, publish: relative(process.cwd(), publish) })

await generateFunctions(constants, appDir)
await generatePagesResolver({ target, constants })
Expand Down
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ describe('onBuild()', () => {
'.next/BUILD_ID',
'.next/static/chunks/webpack-middleware*.js',
'!.next/server/**/*.js.nft.json',
".next/static/css/1152424140993be6.css",
".next/static/css/84099ae0bbc955fa.css",
'!../../node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*',
`!node_modules/next/dist/server/lib/squoosh/**/*.wasm`,
`!node_modules/next/dist/next-server/server/lib/squoosh/**/*.wasm`,
Expand Down