Skip to main content

Programmatic

AssetPack can be run programmatically, allowing you to run AssetPack from your own scripts.

To see a full list of configuration options, see the API Reference.

Usage

To use AssetPack programmatically, you need to import the assetpack function from the assetpack package, and call it with the following options:

import { AssetPack } from '@assetpack/core';

const assetpack = new AssetPack({
entry: './raw-assets',
output: './public/assets',
pipes: [],
});

// To run AssetPack
await assetpack.run();
// Or to watch the assets directory for changes
void assetpack.watch();
// To stop watching the assets directory
assetpack.stop();