Module

@adminjs/bundler

Methods

# static bundle(options)

Bundles AdminJS javascript browser files. This is an alternative to bundling those files on server startup.

The bundled files are stored in "destinationDir". Afterwards, you can for example:

  1. Upload those files to a public storage bucket and tell AdminJS to use files from there:
  const adminJs = new AdminJS({ assetsCDN: <your storage bucket url> })
  1. Serve the "destinationDir" as a public folder, using i. e. express.static:
  app.use(express.static(destinationDir));
  ...
  const adminJs = new AdminJS({ assetsCDN: <your server's url> })

IMPORTANT: To prevent AdminJS from attempting to generate a new bundle on server startup, you must set ADMIN_JS_SKIP_BUNDLE="true" environment variable!

Parameters:
Name Type Description
options BundleConfig

View Source adminjs-bundler/src/bundle.ts, line 23

Example
import { bundle } from '../../src';

(async () => {
  const files = await bundle({
    customComponentsInitializationFilePath: 'src/components/index.ts',
    destinationDir: 'src/public',
  });

  console.log(files);
  // do something with built files here
})();

Type Definitions

object

# AssetsVersioning

Versioning configuration
Properties:
Name Type Description
manifestPath string

Path where you would like your AdminJS assets-manifest file to be saved.

View Source adminjs-bundler/src/bundle.ts, line 153

object

# BundleConfig

Options for the bundler
Properties:
Name Type Attributes Description
destinationDir string

File path where the bundled files should be moved into., , The path is relative to where you run the script.

customComponentsInitializationFilePath string

File path where custom components are bundled. If you have, custom components in your project, they must be bundled in one single file., Please look at the example in the repository., , The path is relative to where you run the script.

adminJsLocalDir string <optional>

File path where AdminJS entry files are generated., , This defaults to '.adminjs'., Set this only if you know what you're doing., , The path is relative to where you run the script.

adminJsAssetsDir string <optional>

File path where AdminJS standard bundle files are located., , This defaults to 'node_modules/adminjs/lib/frontend/assets/scripts'., Set this only if you know what you're doing., , The path is relative to where you run the script.

designSystemDir string <optional>

File path where AdminJS design system bundle files are located., , This defaults to 'node_modules/@adminjs/design-system'., Set this only if you know what you're doing., , The path is relative to where you run the script.

adminJsOptions AdminJSOptions <optional>

You can pass your AdminJS Options config in case you're using external, packages with custom components. It's enough to include only resources section.

versioning AssetsVersioning <optional>

You can define "versioning" if you want your assets to be versioned, e. g., 'app.bundle.123456.js'. Please note that this requires AdminJS version >= 5.8.0, , This will generate a JSON manifest file under specified path (relative to where you run the command)., , The generated file should be linked to assets.coreScripts in your, AdminJS options object.

View Source adminjs-bundler/src/bundle.ts, line 111

object

# BundleFile

AdminJS file config
Properties:
Name Type Description
name string

A file name.

sourcePath string

A source path where the original file can be found.

destinationPath string

A destination path where new bundle file is copied into.

View Source adminjs-bundler/src/bundle.ts, line 161