Skip to main content

Module: @ima/cli

Interfaces

Type Aliases

ImaCliCommand

Ƭ ImaCliCommand: "build" | "dev"

Ima CLI commands.

Defined in

types.ts:25


ImaConfig

Ƭ ImaConfig: Object

Ima config options. Some of these options can be overridden using Args, which takes precedence. These are parsed from optional ima.config.js that can be defined in the root of the IMA.js project.

Type declaration

NameTypeDescription
compressbooleanEnable brotli and gzip compression for production assets [default=true].
cssBrowsersTargetstringBrowserslist configuration string for postcss-preset-env.
devServer?{ hostname?: string ; origin?: string ; port?: number ; publicUrl?: string ; writeToDiskFilter?: (filePath: string) => boolean }HMR dev server settings.
devServer.hostname?string-
devServer.origin?stringOptional custom ima app origin (defaults to http://localhost:[environment.$Server.port]) this is used for CORS configuration.
devServer.port?number-
devServer.publicUrl?string-
devServer.writeToDiskFilter?(filePath: string) => booleanCustom filtr for files which should be always written to disk, even if we're serving static files from memory. This is used for example to always save runner.js to disk, since it's used on server-side too.
disableLegacyBuild?booleanDisables build of 'client' legacy bundle.
experiments?{ css?: boolean }Experimental configurations which can be enabled individually on specific applications. Some of these may find a way to default configuration in future versions of IMA.js.
experiments.css?boolean-
imageInlineSizeLimitnumberThreshold to inline image resources as base64 automatically [default=8192]
jsxRuntime?"classic" | "automatic"Set custom jsxRuntime, the default is 'automatic'.
languagesRecord<string, string[]>Supported languages with glob paths of the files with translations
plugins?ImaCliPlugin[]Optional IMA cli plugins that can be used to easily extend webpack config and cli with additional features.
postcss(config: Record<string, unknown>, ctx: ImaConfigurationContext) => Promise<Record<string, unknown>>Function which receives postcss-loader config and current context, this can be used to customize existing default postcss config or completely replace it with a custom one.
publicPathstringWebpack assets public path [default='']
sourceMaps?boolean | "eval" | "eval-cheap-source-map" | "eval-cheap-module-source-map" | "eval-source-map" | "cheap-source-map" | "cheap-module-source-map" | "source-map" | "inline-cheap-source-map" | "inline-cheap-module-source-map" | "inline-source-map" | "eval-nosources-cheap-source-map" | "eval-nosources-cheap-module-source-map" | "eval-nosources-source-map" | "inline-nosources-cheap-source-map" | "inline-nosources-cheap-module-source-map" | "inline-nosources-source-map" | "nosources-cheap-source-map" | "nosources-cheap-module-source-map" | "nosources-source-map" | "hidden-nosources-cheap-source-map" | "hidden-nosources-cheap-module-source-map" | "hidden-nosources-source-map" | "hidden-cheap-source-map" | "hidden-cheap-module-source-map" | "hidden-source-map"Set to true (or any preset from https://webpack.js.org/configuration/devtool/#devtool) to enable source maps for production build. (dev/watch tasks always generate source maps to work properly with error overlay).
swc(config: Record<string, unknown>, ctx: ImaConfigurationContext) => Promise<Record<string, unknown>>Function which receives default app swc-loader config and current context, this can be used for additional customization or returning completely different config.
swcVendor(config: Record<string, unknown>, ctx: ImaConfigurationContext) => Promise<Record<string, unknown>>Function which receives default vendor swc-loader config and current context, this can be used for additional customization of vendor processed files.
transformVendorPaths?{ exclude?: RegExp[] ; include?: RegExp[] }Advanced functionality allowing you to include/exclude custom vendor paths that go through swc loader (configured using swcVendor function). Use this if you're using dependencies that don't meet the lowest supported ES version target (ES9 by default). all packages in Ima namespace are included by default.
transformVendorPaths.exclude?RegExp[]-
transformVendorPaths.include?RegExp[]-
watchOptionsWatching["watchOptions"]Custom options passed to webpack watch api interface. For more information see: https://webpack.js.org/configuration/watch/#watchoptions
webpack?(config: Configuration, ctx: ImaConfigurationContext, imaConfig: ImaConfig) => Promise<Configuration>Webpack callback function can be used to completely customize default webpack config before it's run.
webpackAliases?ResolveOptions["alias"]Optional custom webpack aliases
prepareConfigurations?(configurations: ImaConfigurationContext[], imaConfig: ImaConfig, args: ImaCliArgs) => Promise<ImaConfigurationContext[]>Called right before creating webpack configurations after preProcess call. This hook lets you customize configuration contexts for each webpack config that will be generated. This is usefull when you need to overrite configuration contexts for values that are not editable anywhere else (like output folders).

Defined in

types.ts:139

Variables

IMA_CONF_FILENAME

Const IMA_CONF_FILENAME: "ima.config.js"

Defined in

webpack/utils.ts:14

Functions

compileLanguages

compileLanguages(imaConfig, rootDir, watch?): Promise<void>

Compile language files defined in imaConfig.

Parameters

NameTypeDefault valueDescription
imaConfigImaConfigundefinedima.config.js file contents.
rootDirstringundefinedCurrent compilation root directory.
watchbooleanfalseWhen set to true, it creates chokidar instances which watch language files for changes and trigger recompilation.

Returns

Promise<void>

Defined in

webpack/languages.ts:203


createCacheKey

createCacheKey(ctx, imaConfig, additionalData?): string

Creates hash representing current webpack environment.

Parameters

NameTypeDescription
ctxImaConfigurationContextCurrent configuration context.
imaConfigImaConfigima configuration
additionalDataObject-

Returns

string

Defined in

webpack/utils.ts:167


createDevServerConfig

createDevServerConfig(«destructured»): Object

Creates hmr dev server configuration from provided contexts and arguments with this priority args -> ctx -> imaConfig -> [defaults].

Parameters

NameType
«destructured»Object
› args?ImaCliArgs
› ctx?ImaConfigurationContext
› imaConfigImaConfig

Returns

Object

NameType
hostnamestring
portnumber
publicUrlstring

Defined in

webpack/utils.ts:122


createWebpackConfig

createWebpackConfig(args, imaConfig): Promise<Configuration[]>

Creates webpack configurations contexts from current config and cli args. Additionally it applies all existing configuration overrides from cli plugins and app overrides in this order cli -> plugins -> app.

Parameters

NameTypeDescription
argsImaCliArgsParsed CLI and build arguments.
imaConfigImaConfigLoaded ima config.

Returns

Promise<Configuration[]>

Defined in

webpack/utils.ts:453


findRules

findRules(config, testString, loader?): RuleSetRule[] | RuleSetUseItem[]

Helper for finding rules with given loader in webpack config.

Parameters

NameType
configConfiguration
testStringstring
loader?string

Returns

RuleSetRule[] | RuleSetUseItem[]

Defined in

webpack/utils.ts:20


getCurrentCoreJsVersion

getCurrentCoreJsVersion(): Promise<any>

Extracts major.minor version string of currently resolved core-js from node_modules.

Returns

Promise<any>

Defined in

webpack/utils.ts:538


getLanguageEntryPoints

getLanguageEntryPoints(languages, rootDir, useHMR?): Record<string, string>

Returns entry points to use in webpack configurations. These then lead to messageformat compiled modules while also containing some additional runtime code.

Parameters

NameTypeDefault valueDescription
languagesRecord<string, string[]>undefinedLanguages object from ima config.
rootDirstringundefinedCurrent compilation root directory.
useHMRbooleanfalse-

Returns

Record<string, string>

Object with webpack entry points.

Defined in

webpack/languages.ts:64


resolveEnvironment

resolveEnvironment(rootDir?): Environment

Loads application IMA.js environment from server/config/environment.js

Parameters

NameTypeDescription
rootDirstringApplication root directory

Returns

Environment

Loaded environment

Defined in

webpack/utils.ts:90


resolveImaConfig

resolveImaConfig(args): Promise<ImaConfig>

Resolves ima.config.js from rootDir base path with DEFAULTS.

Parameters

NameTypeDescription
argsImaCliArgsCLI args.

Returns

Promise<ImaConfig>

Ima config or empty object.

Defined in

webpack/utils.ts:229


runImaPluginsHook

runImaPluginsHook(args, imaConfig, hook): Promise<void>

Runs one of optional ima plugin hooks defined on existing plugins.

Parameters

NameTypeDescription
argsImaCliArgsParsed CLI and build arguments.
imaConfigImaConfigLoaded ima config.
hook"preProcess" | "postProcess"-

Returns

Promise<void>

Defined in

webpack/utils.ts:331