1.2.2 • Published 10 months ago

bun-asset-loader v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

About

This plugin incorporates custom filtered assets into the output directory by copying and optionally modifying them.
It is designed for files that are not imported in any source files.

Please note: Only works on non-Windows based operating systems.

How-To

import assetLoader from 'bun-asset-loader';

const options = {
    assets: [
        {
            from: 'path/to/css/file',
            to: 'path/to/outdir',
            minify: true, // minify CSS, HTML, JSON, etc.
        },
        {
            from: 'path/to/dir',
            to: 'path/to/outdir/subdir',
            filter: /\.(png|jpe?g)$/i, // accepts RegEx and glob patterns
        },
        {
            from: 'path/to/dir',
            // 'to' can be omitted - uses Bun.build 'outdir' as fallback
            filter: '*.json',
            name: 'newName.json',
            transform: (content) => {
                // make the needed changes to the content
                const transformedContent = ... // transform content

                return JSON.stringify(transformedContent);
            },
        },
    ],
};

await Bun.build({
    // ...
    plugins: [
        // ...
        assetLoader(options),
    ],
});

License

Distributed under the MIT License. See MIT License for more information.

1.2.0

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.1.0

1 year ago

1.0.0

1 year ago