-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: load tailwindcss config use jiti
- Loading branch information
Showing
10 changed files
with
47 additions
and
79 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
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
2 changes: 0 additions & 2 deletions
2
packages/toolkit/plugin-v2/src/cli/run/config/createLoadedConfig.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import fs from 'fs'; | ||
import jiti from 'jiti'; | ||
/** | ||
* Load a configuration file dynamically | ||
* @param {string} configFile - Path to the configuration file (absolute or relative) | ||
* @returns {any} - The loaded configuration object | ||
*/ | ||
export function loadConfigContent<T>(configFile: string): T { | ||
// Create a jiti instance | ||
const _require = jiti(__filename, { | ||
esmResolve: true, | ||
// disable require cache to support restart CLI and read the new config | ||
requireCache: false, | ||
interopDefault: true, | ||
}); | ||
// Check if the file exists | ||
if (!fs.existsSync(configFile)) { | ||
throw new Error(`Configuration file does not exist: ${configFile}`); | ||
} | ||
|
||
try { | ||
// Dynamically load the configuration file using jiti | ||
const config = _require(configFile); | ||
|
||
// If the file exports as ESM, access the `default` property | ||
return config.default || config; | ||
} catch (e: any) { | ||
if (e instanceof Error) { | ||
e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${ | ||
e.message || '' | ||
}`; | ||
} | ||
throw e; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.