node package manager

rucksack

rucksack

Support me on Patreon Buy me a book PayPal Version Downloads

JavaScript and CSS bundler.

☁️ Installation

$ npm i --save rucksack

📋 Example

const Rucksack = require("rucksack");
 
 
let bundler = new Rucksack();
 
// Add remote url as resource 
//bundler.add("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"); 
//bundler.add(`${__dirname}/data/main.js`); 
//bundler.add(`${__dirname}/data/another-main.js`); 
bundler.add(`${__dirname}/data/bar.css`);
bundler.add(`${__dirname}/data/main.css`);
bundler.addCSS("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css", false);
bundler.bundleCSS();
bundler.bundleJS();

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. 🐛
  3. For direct and quick help, you can use Codementor. 🚀

📝 Documentation

constructor

Ruckasck Creates a new instance of Ruckasck.

Params

  • Object opts: The Rucksack options.

Return

  • Object The Rucksack instance.

add(resPath, root)

Downloads the script from the resource file.

Params

  • String resPath: The path of the resource.
  • String root: The file's root path.

addJS(resPath, inline)

Downloads the JS scripts from the resource.

Params

  • String resPath: The path of the resource.
  • Boolean inline: Confirms if the resource needs to be downloaded or not.

_watchCSS(resPath)

Watch the CSS paths.

Params

  • String resPath: The CSS resource path.

addCSS(resPath, inline)

Adds a new CSS path.

Params

  • String resPath: The CSS resource path to add.
  • Boolean inline: Whether to add the CSS content inline or not.

bundleJS(output, cb)

Bundles the JS files.

Params

  • String output: The output of the JS script.
  • Function cb: The callback function.

bundleCSS(output, cb)

Bundles the CSS files.

Params

  • String output: The output of the CSS script.
  • Function cb: The callback function.

Return

  • String The URL of the script.

bundle()

Bundles the JS files with the CSS ones.

Return

  • Object

toObject()

Creates an array containing each map to the resources.

Return

  • Array The resources list.

cssHtml()

cssHtml - description Generates the HTML markup for CSS.

Return

  • String The HTML markup.

jsHtml()

Generates the HTML markup for JS.

Return

  • String The HTML markup.

html(resources)

Loads the HTML script.

Params

  • Array resources: The resources list.

Return

  • String The source of the script or stylesheet.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💖 Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! ❤️

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

📜 License

MIT © Ionică Bizău