MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / baseConfig

Function baseConfig

packages/vite/configuration/base.ts:104–505  ·  view source on GitHub ↗
({ mode, flavor }: { mode: string; flavor?: string })

Source from the content-addressed store, hash-verified

102type PlatformType = 'android' | 'ios' | 'visionos';
103
104export const baseConfig = ({ mode, flavor }: { mode: string; flavor?: string }): UserConfig => {
105 const targetMode = mode === 'development' ? 'development' : 'production';
106
107 const cliFlags = getCliFlags();
108 const verbose = resolveVerboseFlag({ env: process.env, cliFlags });
109 // console.log("cliFlags:", cliFlags);
110 const isDevMode = targetMode === 'development';
111 const debug = !!process.env.DEBUG || isDevMode;
112 const hmrActive = isDevMode && !!cliFlags.hmr;
113 let platform = cliFlags.platform as PlatformType;
114 if (cliFlags.android) {
115 platform = 'android';
116 } else if (cliFlags.ios) {
117 platform = 'ios';
118 } else if (cliFlags.visionos) {
119 platform = 'visionos';
120 }
121 if (verbose) {
122 console.log('--------------');
123 // console.log("Vite config mode:", mode);
124 console.log('Platform:', platform);
125 console.log('Mode:', targetMode);
126 console.log('HMR active:', hmrActive);
127 console.log('--------------');
128 }
129
130 flavor = flavor || (getProjectFlavor() as string);
131 if (verbose) {
132 console.log(`Building for ${flavor}.`);
133 }
134
135 // Filtered logger to suppress noisy warnings
136 const filteredLogger = createFilteredViteLogger();
137
138 // Create TypeScript aliases with platform support
139 const tsConfig = getTsConfigData({ platform, verbose });
140
141 // Common resolve configuration for both main and worker builds
142 // Build platform-aware extension preference order and exclude the opposite platform
143 const platformExtensions = (() => {
144 const base = ['.tsx', '.jsx', '.ts', '.js'] as const;
145 const exts: string[] = [];
146 if (platform === 'android') {
147 exts.push('.android.tsx', '.tsx', '.android.jsx', '.jsx', '.android.ts', '.ts', '.android.js', '.js');
148 } else if (platform === 'ios' || platform === 'visionos') {
149 // Treat visionOS like iOS for file resolution
150 exts.push('.ios.tsx', '.tsx', '.ios.jsx', '.jsx', '.ios.ts', '.ts', '.ios.js', '.js');
151 } else {
152 // Fallback: no platform-specific preference
153 exts.push(...base);
154 }
155 // Always allow these last
156 exts.push('.mjs', '.json');
157 return exts;
158 })();
159
160 // Dynamic aliases for nativescript-theme-core generic theme filenames
161 // TODO: move to per-project basis based on usage

Callers 6

angularConfigFunction · 0.85
solidConfigFunction · 0.85
typescriptConfigFunction · 0.85
vueConfigFunction · 0.85
javascriptConfigFunction · 0.85
reactConfigFunction · 0.85

Calls 15

getCliFlagsFunction · 0.85
resolveVerboseFlagFunction · 0.85
getProjectFlavorFunction · 0.85
createFilteredViteLoggerFunction · 0.85
getTsConfigDataFunction · 0.85
packagePlatformAliasesFunction · 0.85
getGlobalDefinesFunction · 0.85
resolveFromAppRootFunction · 0.85
esbuildPlatformResolverFunction · 0.85
createPlatformCssPluginFunction · 0.85

Tested by

no test coverage detected