ts-transform-img
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

ts-transform-img

build status Greenkeeper badge

This is a TypeScript AST Transformer that allows you to write import * as img from 'foo.png'. Depending on file size, the img with be base64-inlined in the source or aggregated via onImgExtracted.

Usage

First of all, you need some level of familiarity with the TypeScript Compiler API.

compile.ts & tests should have examples of how this works. The available options are:

threshold?: number

Threshold of img size that will be inlined, default to 10K

interpolateName?: InterpolateNameFn | string

Function to generate ID for the img asset

onImgExtracted(id: string, filePath: string): void

Function that gets triggered every time we found an asset

/ts-transform-img/

    Package Sidebar

    Install

    npm i ts-transform-img

    Weekly Downloads

    29

    Version

    0.4.2

    License

    MIT

    Unpacked Size

    12.8 kB

    Total Files

    12

    Last publish

    Collaborators

    • longlho