UNPKG

@nx/react-native

Version:

The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: -Integration with libraries such as Jest, Detox, and Storybook. -Scaffolding for creating buildable libraries th

86 lines (85 loc) 3.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createBuildTarget = createBuildTarget; exports.createServeTarget = createServeTarget; exports.createNxWebpackPluginOptions = createNxWebpackPluginOptions; exports.determineTsConfig = determineTsConfig; const devkit_1 = require("@nx/devkit"); function createBuildTarget(tree, options) { return { executor: '@nx/webpack:webpack', outputs: ['{options.outputPath}'], defaultConfiguration: 'production', options: { compiler: 'babel', outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot != '.' ? options.projectRoot : options.project, 'web'), index: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/index.html'), baseHref: '/', main: (0, devkit_1.joinPathFragments)(options.projectRoot, `src/main-web.tsx`), tsConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, determineTsConfig(tree, options)), assets: [ (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/favicon.ico'), (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/assets'), ], webpackConfig: (0, devkit_1.joinPathFragments)(options.projectRoot, 'webpack.config.js'), }, configurations: { development: { extractLicenses: false, optimization: false, sourceMap: true, vendorChunk: true, }, production: { optimization: true, outputHashing: 'all', sourceMap: false, namedChunks: false, extractLicenses: true, vendorChunk: false, }, }, }; } function createServeTarget(options) { return { executor: '@nx/webpack:dev-server', defaultConfiguration: 'development', options: { buildTarget: `${options.project}:build`, hmr: true, }, configurations: { development: { buildTarget: `${options.project}:build:development`, }, production: { buildTarget: `${options.project}:build:production`, hmr: false, }, }, }; } function createNxWebpackPluginOptions(tree, options) { return { target: 'web', compiler: 'babel', outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot != '.' ? options.projectRoot : options.project), index: './src/index.html', baseHref: '/', main: `./src/main-web.tsx`, tsConfig: determineTsConfig(tree, options), assets: ['./src/favicon.ico', './src/assets'], styles: [], }; } function determineTsConfig(tree, options) { const project = (0, devkit_1.readProjectConfiguration)(tree, options.project); const appJson = (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.app.json'); if (tree.exists(appJson)) return 'tsconfig.app.json'; const libJson = (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.lib.json'); if (tree.exists(libJson)) return 'tsconfig.lib.json'; return 'tsconfig.json'; }