Skip to content

Commit

Permalink
feat: support custom cache suffix directory
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Feb 3, 2023
1 parent 9cea69d commit bef2893
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 5 additions & 1 deletion src/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bef2893

Please sign in to comment.