Skip to main content
Version: 3.x

defineExtension

info

Extensions are registered in the application using the front-commerce.config.ts file. Read Register an extension to learn more.

defineExtension

defineExtension allows you to define extensions settings

defineExtension(configuration);

Arguments:

NameTypeDescription
configurationExtensionConfigThe extension configuration

Example:

defineExtension({
name: "acme",
meta: import.meta,
theme: "./extensions/acme/theme",
});

ExtensionConfig

ExtensionConfig is the definition interface of an extension.

name

Required string
Specifies the unique name of the extension.

Example:

{
"name": "acme"
}

meta

Since version 3.4

Required string
Specifies the ImportMeta information of the extension.

Example:

{
"meta": import.meta
}
info

The import.meta should be from the root of your extension. If you defined your extension under a sub-directory, then you should re-export it from the root instead.

📁 hello-v3/
│ ├── 📁 app/
│ ├── 📄 front-commerce.config.ts
│ ├── 📁 extensions/
│ │ ├── 📁 acme-extension/
│ │ │ ├── 📄 index.ts # this is where the import.meta should be located
│ │ │ ├── 📁 extension-def/
│ │ │ │ └── 📄 index.ts
│ │ │ ├── 📁 graphql/
│ │ │ └── 📁 routes/
└── package.json

configuration

Required object
Define configuration

providers

Required ConfigProvider[]
Define configuration provider

theme

Optional string|string[]
Specifies the path to the theme that should be loaded by the application.

Example:

{
"theme": "./extensions/acme/theme"
}

graphql

Optionnal

Configuration for registering GraphQL modules in the unified GraphQL schema.

schema

Optional string|string[]
Defines path(s) to the GraphQL schema file(s) to be loaded in the application.

Example:

{
"schema": [
"./extensions/acme/graphql/foo/**/schema.gql", // accepts a globby pattern
"./extensions/acme/graphql/bar/Feature.gql" // accepts a direct path
]
}

codegen

Optional

CodegenConfig["generates"][] | CodegenConfig["generates"]
configuration for code generation.

translations

Optional string
Specifies the path to the translations directory that should be compiled by the application.

Example:

{
"translations": "./extensions/acme/translations"
}

unstable_lifecycleHooks

caution

This feature is unstable and may change in the future.

Optional

Specifies the lifecycle hooks that should be executed by the application. These hooks allow you to register custom logic at specific points of the application lifecycle.

Example:

{
unstable_lifecycleHooks: {
onServerServicesInit: async (services, request, config) => {
// Do something with the services
};
}
}

onServerServicesInit

Called when the server services are initialized with the following params: