Module: @ima/cli
Interfaces
Type Aliases
ImaCliCommand
Ƭ ImaCliCommand: "build"
| "dev"
Ima CLI commands.
Defined in
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
Name | Type | Description |
---|---|---|
compress | boolean | Enable brotli and gzip compression for production assets [default=true]. |
cssBrowsersTarget | string | Browserslist 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? | string | Optional 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 ) => boolean | Custom 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? | boolean | Disables 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 | - |
imageInlineSizeLimit | number | Threshold to inline image resources as base64 automatically [default=8192] |
jsxRuntime? | "classic" | "automatic" | Set custom jsxRuntime, the default is 'automatic'. |
languages | Record <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. |
publicPath | string | Webpack 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 [] | - |
watchOptions | Watching ["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
Variables
IMA_CONF_FILENAME
• Const
IMA_CONF_FILENAME: "ima.config.js"
Defined in
Functions
compileLanguages
▸ compileLanguages(imaConfig
, rootDir
, watch?
): Promise
<void
>
Compile language files defined in imaConfig.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
imaConfig | ImaConfig | undefined | ima.config.js file contents. |
rootDir | string | undefined | Current compilation root directory. |
watch | boolean | false | When set to true, it creates chokidar instances which watch language files for changes and trigger recompilation. |
Returns
Promise
<void
>
Defined in
createCacheKey
▸ createCacheKey(ctx
, imaConfig
, additionalData?
): string
Creates hash representing current webpack environment.
Parameters
Name | Type | Description |
---|---|---|
ctx | ImaConfigurationContext | Current configuration context. |
imaConfig | ImaConfig | ima configuration |
additionalData | Object | - |
Returns
string
Defined in
createDevServerConfig
▸ createDevServerConfig(«destructured»
): Object
Creates hmr dev server configuration from provided contexts and arguments with this priority args -> ctx -> imaConfig -> [defaults].
Parameters
Name | Type |
---|---|
«destructured» | Object |
› args? | ImaCliArgs |
› ctx? | ImaConfigurationContext |
› imaConfig | ImaConfig |
Returns
Object
Name | Type |
---|---|
hostname | string |
port | number |
publicUrl | string |
Defined in
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
Name | Type | Description |
---|---|---|
args | ImaCliArgs | Parsed CLI and build arguments. |
imaConfig | ImaConfig | Loaded ima config. |
Returns
Promise
<Configuration
[]>
Defined in
findRules
▸ findRules(config
, testString
, loader?
): RuleSetRule
[] | RuleSetUseItem
[]
Helper for finding rules with given loader in webpack config.
Parameters
Name | Type |
---|---|
config | Configuration |
testString | string |
loader? | string |
Returns
RuleSetRule
[] | RuleSetUseItem
[]
Defined in
getCurrentCoreJsVersion
▸ getCurrentCoreJsVersion(): Promise
<any
>
Extracts major.minor version string of currently resolved core-js from node_modules.
Returns
Promise
<any
>
Defined in
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
Name | Type | Default value | Description |
---|---|---|---|
languages | Record <string , string []> | undefined | Languages object from ima config. |
rootDir | string | undefined | Current compilation root directory. |
useHMR | boolean | false | - |
Returns
Record
<string
, string
>
Object with webpack entry points.
Defined in
resolveEnvironment
▸ resolveEnvironment(rootDir?
): Environment
Loads application IMA.js environment from server/config/environment.js
Parameters
Name | Type | Description |
---|---|---|
rootDir | string | Application root directory |
Returns
Loaded environment
Defined in
resolveImaConfig
▸ resolveImaConfig(args
): Promise
<ImaConfig
>
Resolves ima.config.js from rootDir base path with DEFAULTS.
Parameters
Name | Type | Description |
---|---|---|
args | ImaCliArgs | CLI args. |
Returns
Promise
<ImaConfig
>
Ima config or empty object.
Defined in
runImaPluginsHook
▸ runImaPluginsHook(args
, imaConfig
, hook
): Promise
<void
>
Runs one of optional ima plugin hooks defined on existing plugins.
Parameters
Name | Type | Description |
---|---|---|
args | ImaCliArgs | Parsed CLI and build arguments. |
imaConfig | ImaConfig | Loaded ima config. |
hook | "preProcess" | "postProcess" | - |
Returns
Promise
<void
>