generated from sonofmagic/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tailwindcss-patch): commit patches foldor
- Loading branch information
1 parent
e80eb67
commit bcbebab
Showing
9 changed files
with
83 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './tw-patcher' | ||
export * from './inspector' | ||
export * from './patches' | ||
export * from './runtime-patcher' | ||
export * from './cache' |
73 changes: 73 additions & 0 deletions
73
packages/tailwindcss-patch/src/core/patches/exportContext/index.ts
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,73 @@ | ||
import path from 'node:path' | ||
import fs from 'node:fs' | ||
import { inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext } from './postcss' | ||
import { inspectPostcssPlugin as inspectPostcssPluginCompat, inspectProcessTailwindFeaturesReturnContext as inspectProcessTailwindFeaturesReturnContextCompat } from './postcss-compat' | ||
import type { InternalPatchOptions } from '@/types' | ||
import { ensureFileContent } from '@/utils' | ||
|
||
export function monkeyPatchForExposingContextV3(twDir: string, opt: InternalPatchOptions) { | ||
const processTailwindFeaturesFilePath = path.resolve(twDir, 'lib/processTailwindFeatures.js') | ||
|
||
const processTailwindFeaturesContent = ensureFileContent(processTailwindFeaturesFilePath) | ||
const result: { processTailwindFeatures?: string, plugin?: string } & Record<string, any> = {} | ||
if (processTailwindFeaturesContent) { | ||
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContext(processTailwindFeaturesContent) | ||
if (!hasPatched && opt.overwrite) { | ||
fs.writeFileSync(processTailwindFeaturesFilePath, code, { | ||
encoding: 'utf8', | ||
}) | ||
console.log('patch tailwindcss processTailwindFeatures for return content successfully!') | ||
} | ||
result.processTailwindFeatures = code | ||
} | ||
|
||
const pluginFilePath = path.resolve(twDir, 'lib/plugin.js') | ||
const indexFilePath = path.resolve(twDir, 'lib/index.js') | ||
const pluginContent = ensureFileContent([pluginFilePath, indexFilePath]) | ||
if (pluginContent) { | ||
const { code, hasPatched } = inspectPostcssPlugin(pluginContent) | ||
if (!hasPatched && opt.overwrite) { | ||
fs.writeFileSync(pluginFilePath, code, { | ||
encoding: 'utf8', | ||
}) | ||
console.log('patch tailwindcss for expose runtime content successfully!') | ||
} | ||
result.plugin = code | ||
} | ||
|
||
opt.custom && typeof opt.custom === 'function' && opt.custom(twDir, result) | ||
return result | ||
} | ||
|
||
export function monkeyPatchForExposingContextV2(twDir: string, opt: InternalPatchOptions) { | ||
const processTailwindFeaturesFilePath = path.resolve(twDir, 'lib/jit/processTailwindFeatures.js') | ||
|
||
const processTailwindFeaturesContent = ensureFileContent(processTailwindFeaturesFilePath) | ||
const result: { processTailwindFeatures?: string, plugin?: string } & Record<string, any> = {} | ||
if (processTailwindFeaturesContent) { | ||
const { code, hasPatched } = inspectProcessTailwindFeaturesReturnContextCompat(processTailwindFeaturesContent) | ||
if (!hasPatched && opt.overwrite) { | ||
fs.writeFileSync(processTailwindFeaturesFilePath, code, { | ||
encoding: 'utf8', | ||
}) | ||
console.log('patch tailwindcss processTailwindFeatures for return content successfully!') | ||
} | ||
result.processTailwindFeatures = code | ||
} | ||
|
||
const indexFilePath = path.resolve(twDir, 'lib/jit/index.js') | ||
const pluginContent = ensureFileContent([indexFilePath]) | ||
if (pluginContent) { | ||
const { code, hasPatched } = inspectPostcssPluginCompat(pluginContent) | ||
if (!hasPatched && opt.overwrite) { | ||
fs.writeFileSync(indexFilePath, code, { | ||
encoding: 'utf8', | ||
}) | ||
console.log('patch tailwindcss for expose runtime content successfully!') | ||
} | ||
result.plugin = code | ||
} | ||
|
||
opt.custom && typeof opt.custom === 'function' && opt.custom(twDir, result) | ||
return result | ||
} |
File renamed without changes.
File renamed without changes.
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 @@ | ||
export * from './exportContext' |
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
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