@@ -71,20 +71,26 @@ export class GeneratedFileWriter {
71
71
72
72
private generateFileContent = ( ) : string => {
73
73
// Evaluate the config as a JS object
74
- const configEval = vm . runInNewContext ( this . _configFileData , { require, module : { } } ) as TConfig ;
74
+ const evaluatedConfig = < TConfig > vm . runInNewContext ( this . _configFileData , {
75
+ __dirname : path . dirname ( path . resolve ( `./${ this . _configFilename } ` ) ) ,
76
+ module : { } ,
77
+ require,
78
+ } ) ;
75
79
76
80
// Parse the config with the config parser class
77
- const scanner = new TailwindConfigParser ( configEval , {
81
+ const configParser = new TailwindConfigParser ( evaluatedConfig , {
78
82
pluginTypography : this . _configFileData . includes ( '@tailwindcss/typography' ) ,
79
83
pluginCustomForms : this . _configFileData . includes ( '@tailwindcss/custom-forms' ) ,
80
84
} ) ;
81
85
82
86
// Generate all classnames from the config
83
- const generatedClassnames = new ClassnamesGenerator ( scanner ) . generate ( ) ;
87
+ const generatedClassnames = new ClassnamesGenerator ( configParser ) . generate ( ) ;
84
88
85
- // Create the file content from the generated classes
86
- const contentGenerator = new FileContentGenerator ( generatedClassnames , scanner . getPrefix ( ) ) ;
87
- const fileContentTemplate = contentGenerator . generateFileContent ( ) ;
89
+ // Create the file content from the generated classnames
90
+ const fileContentTemplate = new FileContentGenerator (
91
+ generatedClassnames ,
92
+ configParser . getPrefix ( ) ,
93
+ ) . generateFileContent ( ) ;
88
94
89
95
// Resolve the custom classes import path relative to the output file
90
96
let customClassesImportPath : string | null = null ;
0 commit comments