diff options
| author | 2023-04-28 01:36:44 +0800 | |
|---|---|---|
| committer | 2023-04-28 01:36:44 +0800 | |
| commit | dd84b9d64fb98746a230cd24233ff50a562c39c9 (patch) | |
| tree | b583261ef00b3afe72ec4d6dacb31e57779a6faf /packages/turbo-tracing-next-plugin/src | |
| parent | 0b46fcd72ac34382387b2bcf9095233efbcc52f4 (diff) | |
| download | HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.tar.gz HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.zip | |
Diffstat (limited to 'packages/turbo-tracing-next-plugin/src')
| -rw-r--r-- | packages/turbo-tracing-next-plugin/src/index.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/turbo-tracing-next-plugin/src/index.ts b/packages/turbo-tracing-next-plugin/src/index.ts new file mode 100644 index 0000000..0b75113 --- /dev/null +++ b/packages/turbo-tracing-next-plugin/src/index.ts @@ -0,0 +1,27 @@ +import { + NodeModuleTracePlugin, + NodeModuleTracePluginOptions, +} from "@vercel/webpack-nft"; +import type { NextConfig } from "next"; + +export function createNodeFileTrace(options?: NodeModuleTracePluginOptions) { + return function withNodeFileTrace(config: NextConfig = {}) { + const createWebpackConfig = config.webpack; + config.outputFileTracing = false; + config.webpack = (webpackConfig, context) => { + const config = + createWebpackConfig?.(webpackConfig, context) ?? webpackConfig; + if (context.isServer && !context.dev) { + const plugin = new NodeModuleTracePlugin(options); + if (config.plugins) { + config.plugins.push(plugin); + } else { + config.plugins = [plugin]; + } + } + + return config; + }; + return config; + }; +} |
