UNPKG

@rnv/engine-rn-next

Version:

ReNative Engine to build next based platforms with react native support.

66 lines 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EnvVars = void 0; var tslib_1 = require("tslib"); var core_1 = require("@rnv/core"); var path_1 = tslib_1.__importDefault(require("path")); var runner_1 = require("./runner"); exports.EnvVars = { RNV_NEXT_TRANSPILE_MODULES: function () { return { RNV_NEXT_TRANSPILE_MODULES: getTranspileModules(), }; }, NEXT_BASE: function () { return _checkPagesDir(); }, NODE_ENV: function () { var env = (0, core_1.getConfigProp)('environment'); return { NODE_ENV: env || 'development', }; }, }; var getTranspileModules = function () { var c = (0, core_1.getContext)(); var transModules = (0, core_1.getConfigProp)('nextTranspileModules') || []; (0, core_1.parsePlugins)(function (plugin, pluginPlat, key) { var _a; var webpackConfig = plugin.webpackConfig; if (webpackConfig) { transModules.push(key); if ((_a = webpackConfig.nextTranspileModules) === null || _a === void 0 ? void 0 : _a.length) { webpackConfig.nextTranspileModules.forEach(function (module) { if (module.startsWith('.')) { transModules.push(path_1.default.join(c.paths.project.dir, module)); } else { transModules.push(module); } }); } } }, true); return transModules; }; var _checkPagesDir = function () { var c = (0, core_1.getContext)(); var pagesDir = (0, core_1.getConfigProp)('pagesDir'); var distDir = (0, runner_1.getExportDir)(c); var isExport = c._currentTask === 'export'; if (pagesDir) { var pagesDirPath = path_1.default.join(c.paths.project.dir, pagesDir); if (!(0, core_1.fsExistsSync)(pagesDirPath)) { (0, core_1.logWarning)("You configured custom ".concat(c.platform, "pagesDir: ").concat((0, core_1.chalk)().bold.white(pagesDir), " in your renative.json but it is missing at ").concat((0, core_1.chalk)().red(pagesDirPath))); } return { NEXT_PAGES_DIR: pagesDir, NEXT_DIST_DIR: distDir, NEXT_EXPORT: isExport }; } var fallbackPagesDir = 'src/app'; (0, core_1.logWarning)("You're missing ".concat(c.platform, ".pagesDir config. Defaulting to '").concat(fallbackPagesDir, "'")); var fallbackPagesDirPath = path_1.default.join(c.paths.project.dir, fallbackPagesDir); if (!(0, core_1.fsExistsSync)(fallbackPagesDirPath)) { (0, core_1.logWarning)("Folder ".concat((0, core_1.chalk)().bold.white(fallbackPagesDir), " is missing. make sure your entry code is located there in order for next to work correctly!\nAlternatively you can configure custom entry folder via ").concat(c.platform, ".pagesDir in renative.json")); } return { NEXT_PAGES_DIR: 'src/app', NEXT_DIST_DIR: distDir, NEXT_EXPORT: isExport }; }; //# sourceMappingURL=env.js.map