Skip to content

fix: switch to globby for static files #778

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 1 commit into from
Nov 8, 2021
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
51 changes: 11 additions & 40 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@vercel/node": "^1.11.2-canary.4",
"chalk": "^4.1.2",
"fs-extra": "^10.0.0",
"globby": "^11.0.4",
"moize": "^6.1.0",
"node-fetch": "^2.6.6",
"node-stream-zip": "^1.15.0",
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const { cpus } = require('os')

const { existsSync, readJson, move, cpSync, copy, writeJson } = require('fs-extra')
const globby = require('globby')
const pLimit = require('p-limit')
const { join } = require('pathe')
const slash = require('slash')
const glob = require('tiny-glob')

const TEST_ROUTE = /(|\/)\[[^/]+?](\/|\.html|$)/

Expand All @@ -24,7 +24,7 @@ exports.moveStaticPages = async ({ netlifyConfig, target, i18n, failBuild }) =>
await move(source, dest)
}
// Move all static files, except error documents and nft manifests
const pages = await glob('**/!(500|404|*.js.nft).{html,json}', {
const pages = await globby(['**/*.{html,json}', '!**/(500|404|*.js.nft).{html,json}'], {
cwd: root,
dot: true,
})
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('onBuild()', () => {
process.env.EXPERIMENTAL_MOVE_STATIC_PAGES = 'true'
await plugin.onBuild(defaultArgs)
expect(existsSync(path.resolve('.next/static-manifest.json'))).toBeTruthy()
const data = JSON.parse(readFileSync(path.resolve('.next/static-manifest.json'), 'utf8'))
const data = JSON.parse(readFileSync(path.resolve('.next/static-manifest.json'), 'utf8')).sort()
expect(data).toMatchSnapshot()
delete process.env.EXPERIMENTAL_MOVE_STATIC_PAGES
})
Expand Down