-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support disabling codegen in certain modes
Adds a plugin config that provides support for disabling codegen under different modes
- Loading branch information
1 parent
92690a0
commit 9c546a7
Showing
6 changed files
with
98 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CodegenContext } from '@graphql-codegen/cli'; | ||
|
||
export function isCodegenConfig( | ||
filePath: string, | ||
context: CodegenContext | ||
): boolean { | ||
const configPath = context.filepath; | ||
return configPath === filePath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import fs from 'fs'; | ||
|
||
export function restartVite(fileName: string) { | ||
if (!fileName) return; | ||
|
||
const time = new Date(); | ||
|
||
try { | ||
fs.utimesSync(fileName, time, time); | ||
} catch (error) { | ||
fs.closeSync(fs.openSync(fileName, 'w')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ConfigEnv } from 'vite'; | ||
|
||
export type ViteMode = ConfigEnv['command']; | ||
|
||
const modes = { | ||
serve: 'serve', | ||
build: 'build', | ||
} as { [K in ViteMode]: K }; | ||
|
||
export const isServeMode = (mode: ViteMode) => mode === modes.serve; | ||
|
||
export const isBuildMode = (mode: ViteMode) => mode === modes.build; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters