Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

jonahsnider/netlify-cache-nextjs

Repository files navigation

⚠️ DEPRECATED ⚠️

This plugin is no longer maintained.

Please use Netlify's official build plugin for Next.js for the same caching functionality.

Cache the Next.js build folder in Netlify builds.

add to netlify npm downloads per week Build Status XO code style

A popular Netlify build plugin.

Usage

This is a Netlify build plugin, which will run during your Netlify builds. You can learn more about Netlify Build Plugins in the Netlify docs.

add to netlify

If you want to manually install the plugin add the following lines to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-cache-nextjs"

Next, from your project's base directory, use yarn, npm, or any other Node.js package manager to add this plugin to devDependencies in package.json.

yarn add -D netlify-plugin-cache-nextjs

If you want to configure the plugin, you can do this in your netlify.toml file:

[[plugins]]
package = "netlify-plugin-cache-nextjs"
	# These options will cache the build directory at `${NETLIFY_BASE}/frontend/.next-build`
	[plugins.inputs]
	# The path to the build directory
	build_dir_path = "frontend"
	# Custom build directory if you aren't using `.next` (https://nextjs.org/docs/api-reference/next.config.js/setting-a-custom-build-directory)
	custom_build_dir_name = ".next-build"

Note: The [[plugins]] line is required for each plugin, even if you have other plugins in your netlify.toml file already.

Contributing

Prequisites

This project uses any Node.js version Netlify supports (8-13). For best results use the latest Node.js LTS version.

This project uses Yarn to install dependencies, although you can use another package manager like npm or pnpm.

yarn install
# or `npm install`
# or `pnpm install`

Building

Run the build script to compile and optimize the TypeScript code into the dist folder.

Style

This project uses Prettier and XO.

You can run Prettier in the project with this command:

yarn run style

You can run XO with this command:

yarn run lint

Note that XO will also error if you have TypeScript errors, not just if your formatting is incorrect.

Linting

This project uses XO (which uses ESLint and some plugins internally) to perform static analysis on the TypeScript. It reports things like unused variables or not following code conventions.

yarn run lint

Note that XO will also error if you have incorrect formatting, not just if your TypeScript code has errors.