JavaScript and CSS bundler.
# Using npm
npm install --save rucksack
# Using yarn
yarn add rucksack
const Rucksack = require("rucksack")
// Create a new bundler
let bundler = new Rucksack({
aliases: {
"foo": `${__dirname}/data/bar/foo.js`
}
})
// 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.add({
// type: "css",
// url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css",
// inline: true
//})
bundler.bundleCSS(`${__dirname}/test.css`)
// => info [Tuesday, November 28, 2017 06:53:48 AM] Bundling the styles.
// => warn [Tuesday, November 28, 2017 06:53:48 AM] Skipping remote @import of "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css" as resource is not allowed.
// => @import url(https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css);strong{color:#000}strong{color:#ff0}body{background:#fff;-webkit-transform:translate(10px);transform:translate(10px)}
bundler.bundleJS(`${__dirname}/test.js`)
// => info [Tuesday, November 28, 2017 06:53:48 AM] Bundling the scripts.
// => (function e(t,n,r){...})
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. π
Ruckasck
Creates a new instance of Ruckasck
.
- Object
opts
: The Rucksack options.
- Object The Rucksack instance.
Watch the CSS paths.
- String
resPath
: The CSS resource path.
Adds a new CSS path.
- String
resPath
: The CSS resource path to add. - Boolean
inline
: Whether to add the CSS content inline or not.
Bundles the JS files.
- String
output
: The output of the JS script. - Function
cb
: The callback function.
Bundles the CSS files.
- String
output
: The output of the CSS script. - Function
cb
: The callback function.
- String The URL of the script.
Have an idea? Found a bug? See how to contribute.
If you are using this library in one of your projects, add it in this list. β¨
bloggify
bloggify-cli
bloggify-prebuilt