MCPcopy Create free account
hub / github.com/craftreactnative/ui / createBabelConfig

Function createBabelConfig

cli/src/utils/build-config.ts:18–44  ·  view source on GitHub ↗
(
  targetPath: string,
  rootFolder: string
)

Source from the content-addressed store, hash-verified

16 * Creates a new babel.config.js file with the unistyles plugin
17 */
18export 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

Callers 1

setupBabelConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected