-
Notifications
You must be signed in to change notification settings - Fork 92
Closed
Labels
proj/non/next-on-netlify-enterprisetype: featurecode contributing to the implementation of a feature and/or user facing functionalitycode contributing to the implementation of a feature and/or user facing functionality
Description
We could use the cache
utility to cache .next/cache
between builds, to speed up Next.js builds.
An existing plugin is already doing it (source code). Since that plugin allows users to customize the path to .next/cache/
, it could still be useful for the few users who need that. @lindsaylevine Do you think using a custom file path for .next/
is common?
Without that case in mind, adding this would probably look like this:
const CACHE_DIR = '.next/cache/'
const BUILD_MANIFEST = '.next/build-manifest.json'
module.exports = {
async onPreBuild({ utils }) {
if (await utils.cache.restore(CACHE_DIR)) {
console.log('Next.js cache restored.')
} else {
console.log('No Next.js cache to restore')
}
},
async onPostBuild({ utils }) {
if (await utils.cache.save(CACHE_DIR, { digests: [BUILD_MANIFEST] })) {
console.log('Next.js cache saved.')
} else {
console.log('No Next.js cache to save.')
}
}
}
What do you think?
neefrehman and oliviertassinari
Metadata
Metadata
Assignees
Labels
proj/non/next-on-netlify-enterprisetype: featurecode contributing to the implementation of a feature and/or user facing functionalitycode contributing to the implementation of a feature and/or user facing functionality