Coder Social home page Coder Social logo

packify's Introduction

packify

packs up browserify apps by inlining all assets into one html file

npm install packify -g
packify index.html > packed.html

dat

how it works

packify will do the following transformations:

  • <img src="foo.png"> -> <img src="data:...">
  • <link rel="stylesheet" href="foo.css"> -> <style> /** styles here **/ </style>
  • <script src="foo.js"> -> <script> /** browserified foo.js here **/ </script>
  • background-image { url(foo.png) } -> background-image { url('data:...') }

all transformations are handled by dependencies: inline-images, inline-styles, imageinliner and scriptify

notes:

  • url(foo.png) inside stylesheets will also get converted to inline data-uris
  • only relative URIs will be transformed, e.g. <script src="http://foo.com/foo.js"> will be ignored

example

the dat-editor module/application uses this.

before packify: https://github.com/maxogden/dat-editor/blob/master/index.html after packify: https://github.com/maxogden/dat-editor/blob/master/prebuilt.html

prebuilt.html is generated by this npm command https://github.com/maxogden/dat-editor/blob/master/package.json#L8 (note the brfs transform https://github.com/maxogden/dat-editor/blob/master/package.json#L28-L32)

usage

javascript

var packify = require('packify')

var opts = {
  html: "<html> ... your html here... </html>",
  args: ['arguments', 'for', 'browserify'],
  selector: 'script' // css selector passed to scriptify for it to select elements to browserify
}

packify(opts, function(err, packed) {
  console.log(packed.toString())
})

CLI

packify <path-to-html-file>

when using on the CLI any additional arguments beyond the HTML file will be passed straight to browserify, e.g.

packify index.html -t brfs

will run browserify like browserify -t brfs

packify's People

Contributors

max-mapper avatar bclinkinbeard avatar

Watchers

Marc Juul avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.