| 16 | * Creates a new babel.config.js file with the unistyles plugin |
| 17 | */ |
| 18 | export async function createBabelConfig( |
| 19 | targetPath: string, |
| 20 | rootFolder: string |
| 21 | ): Promise<void> { |
| 22 | const babelConfigPath = path.join(targetPath, "babel.config.js"); |
| 23 | |
| 24 | const babelConfig = `module.exports = function (api) { |
| 25 | api.cache(true); |
| 26 | |
| 27 | return { |
| 28 | presets: ['babel-preset-expo'], |
| 29 | plugins: [ |
| 30 | [ |
| 31 | '${UNISTYLES_PLUGIN}', |
| 32 | { |
| 33 | // pass root folder of your application |
| 34 | // all files under this folder will be processed by the Babel plugin |
| 35 | root: '${rootFolder}', |
| 36 | }, |
| 37 | ], |
| 38 | ], |
| 39 | }; |
| 40 | }; |
| 41 | `; |
| 42 | |
| 43 | await fs.writeFile(babelConfigPath, babelConfig, "utf8"); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Modifies an existing babel.config.js file to add the unistyles plugin |