mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
chore: more base configuration
This commit is contained in:
@ -2,6 +2,7 @@ import Config from 'webpack-chain';
|
||||
import webpack from 'webpack';
|
||||
import { configs } from './configuration';
|
||||
import { determineProjectFlavor } from './helpers/flavor';
|
||||
import { highlight } from 'cli-highlight';
|
||||
|
||||
export type Platform = 'android' | 'ios' | string;
|
||||
|
||||
@ -17,14 +18,21 @@ export interface IWebpackEnv {
|
||||
production?: boolean;
|
||||
report?: boolean;
|
||||
hmr?: boolean;
|
||||
|
||||
// enable verbose output
|
||||
verbose?: boolean;
|
||||
// todo: add others
|
||||
}
|
||||
|
||||
let webpackChains: any[] = [];
|
||||
let webpackMerges: any[] = [];
|
||||
let env: IWebpackEnv = {};
|
||||
let explicitUseConfig = false;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export let env: IWebpackEnv = {};
|
||||
|
||||
////// PUBLIC API
|
||||
export const defaultConfigs = configs;
|
||||
|
||||
@ -34,9 +42,11 @@ export function init(_env: IWebpackEnv) {
|
||||
}
|
||||
}
|
||||
|
||||
export function useConfig(config: keyof typeof defaultConfigs) {
|
||||
export function useConfig(config: keyof typeof defaultConfigs | false) {
|
||||
explicitUseConfig = true;
|
||||
webpackChains.push(configs[config]);
|
||||
if (config) {
|
||||
webpackChains.unshift(configs[config]);
|
||||
}
|
||||
}
|
||||
|
||||
export function chainWebpack(chainFn: (config: Config, env: IWebpackEnv) => any) {
|
||||
@ -59,6 +69,11 @@ export function resolveChainableConfig() {
|
||||
return chainFn(config, env);
|
||||
});
|
||||
|
||||
if (env.verbose) {
|
||||
console.log('Resolved chainable config:');
|
||||
console.log(highlight(config.toString(), { language: 'js' }));
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user