makestatic-fingerprint

    1.0.12 • Public • Published

    Fingerprint

    Fingerprint output files and update references



    Install

    yarn add makestatic-fingerprint
    

    API

    Fingerprint

    Fingerprints output files for cache busting. Rewrites the references to the resources and renames the corresponding compilation assets.

    Enable this plugin for the emit phase.

    Fingerprinting uses a checksum of the file content to generate a unique name for the file, references to the resource are renamed and the corresponding output file is renamed.

    Because this plugin is enabled during the emit phase you can be certain that the generated checksums match the actual checksums of the referenced files as the files have been optimized and sealed.

    See Also

    Fingerprint

    new Fingerprint(context, options)

    Create a Fingerprint plugin.

    The rules option is an array of regular expression resource patterns.

    When no id function is specified the default implementation will generate a checksum of the resource file content. When no name function is given it generates a name prepending a period and the generated id before the file extension.

    The signature for an id function is:

    id(file, content)

    It should return a unique identifier for the file.

    The signature for a name function is:

    name(file, id)

    It should return the new name of the file based on the supplied id.

    You may change the checksum algorithm using the algorithm option but it is recommended you use the default.

    • context Object the processing context.
    • options Object the plugin options.
    Options
    • rules Array list of resource matching rules.
    • algorithm String=sha512 checksum algorithm.
    • id Function generate fingerprint id.
    • name Function generate new resource file name.
    Throws
    • Error if no resource graph is available.

    .sources

    Fingerprint.prototype.sources(file, context)

    Inspects the rules assigned to this plugin and finds matching resources.

    For each matched resource call the id function to generate a unique identifier for the resource followed by the name function to generate a new name for the resource.

    Once the resource name has been allocated references to the resource are renamed and compilation asset output paths are renamed.

    • file Object the current file.
    • context Object the processing context.
    Throws
    • Error if a resource could not be found in the graph.

    License

    MIT


    Created by mkdoc on March 12, 2017

    Install

    npm i makestatic-fingerprint

    DownloadsWeekly Downloads

    29

    Version

    1.0.12

    License

    MIT

    Last publish

    Collaborators

    • tmpfs