Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Add functionality to manually include files in the build #4

@zanona

Description

@zanona

sometimes, file names are dynamically generated through javascript.
This means that the parser won't understand that as an url and the file won't be included in the final build.

Review implementation based on CLI flag --include <glob>

pakku index.html build --include products/**

However, this also means versionised file names will eventually break on javascript call like.

getImage('products/' + number + '.jpg');

With that in mind, adding a route map object on the script containing invocation to those images might be a good idea. This way, pack would inject the pakku object inside window scope including file routing.

window.pakku = {
  'products/101.jpg': 'products-101-d3kfj4g.jpg'
  'products/102.jpg': 'products-102-kdjfkj4.jpg'
};

from the same script, the user can add the following method to implement pack compatibility.

function getImage(src) { return window.pakku && window.pakku[src] || src; }

falling back, gracefully on development.

Once the parser find a mention to ``window.pakkuorpakku` inside the script, it will automatically prepend the routing object to it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions