From bef28937788cd9e136e66e7815de54714ae64c4e Mon Sep 17 00:00:00 2001 From: David Heidrich Date: Fri, 3 Feb 2023 16:09:04 -0500 Subject: [PATCH] feat: support custom cache suffix directory --- README.md | 5 +++++ src/webpack/webpack.config.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0135d2e..eda454e 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ Add the following script to your application } ``` +### Command args + +- `--env cacheSuffix=custom-cache-suffix`, you can provide a custom cache suffix, this use `cacheSuffix` as subdirectory + under the default cache directory (`.next-static/cache/webpack/yourSuffix`). + This command will dump all compilation output into a new folder called `.next-static`. Make sure you include this folder into your build process / Dockerfile. diff --git a/src/webpack/webpack.config.ts b/src/webpack/webpack.config.ts index 5c81848..a74f08f 100644 --- a/src/webpack/webpack.config.ts +++ b/src/webpack/webpack.config.ts @@ -16,6 +16,7 @@ import { INIT_ENTRY, SHELL_ENTRY, STATIC_PATH } from '../const.js' interface Args { /** the entry point of the application */ entry: string + cacheSuffix?: string } export const parallelism = 2 @@ -83,7 +84,10 @@ export default async (env: Args) => { } const outputPath = path.join(context, '.next-static') - const webpackCacheFolder = path.join(outputPath, 'cache', 'webpack') + const baseCacheFolder = path.join(outputPath, 'cache', 'webpack') + const webpackCacheFolder = env.cacheSuffix + ? path.join(baseCacheFolder, env.cacheSuffix) + : baseCacheFolder const baseAliases = { '@main': appAlias,