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

Add functionality to manually include files in the build #4

Open
zanona opened this issue Feb 27, 2015 · 0 comments
Open

Add functionality to manually include files in the build #4

zanona opened this issue Feb 27, 2015 · 0 comments

Comments

@zanona
Copy link
Owner

zanona commented Feb 27, 2015

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.

@zanona zanona self-assigned this Feb 27, 2015
@zanona zanona removed their assignment Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant