Skip to main content

Static Assets Plugin

The staticAssetPlugin is a built-in Coralite utility that orchestrates copying raw files directly into the final build directory. It supports both local path resolution and NPM package traversal to pull binary assets (like .wasm files), images, or scripts out of node_modules.

Configuration #

The plugin is automatically initialized if you provide an assets array to the Coralite configuration. Each object in the array must contain a dest (destination) property.

Local File Resolution #

If the asset object contains a src property, the plugin copies the file or directory directly from your local file system.

JavaScript
Code copied!
  // coralite.config.js
  export default defineConfig({
    assets: [
      { src: './src/public/favicon.ico', dest: 'favicon.ico' },
      { src: './src/docs/pdf', dest: 'assets/pdf' } // Copies whole directory
    ]
  });

NPM Package Resolution #

If src is missing, you must provide pkg and path properties. The plugin uses Node's resolution logic to find the package root and then appends the provided path.

JavaScript
Code copied!
  // coralite.config.js
  export default defineConfig({
    assets: [
      { 
        pkg: '@matrix-org/matrix-sdk-crypto-wasm', 
        path: 'pkg/matrix_sdk_crypto_wasm_bg.wasm', 
        dest: 'assets/js/matrix_sdk_crypto_wasm_bg.wasm' 
      }
    ]
  });

How it Works #

Start Building with Coralite!

Use the scaffolding script to get jump started into your next project with Coralite

Copied commandline!