Giter VIP home page Giter VIP logo

packular's Introduction

packular

Packular reads lists of required JavaScript, CSS, and partial HTML files, and downloads/combines/references them in index.html files for use in development and production. It supports pre-loading AngularJS templates via $templateCache.

Packular is a Python solution without any dependencies. If you are looking for a JavaScript based implementation with similar features, grunt is a good match.

packular.conf

When no command line options are given, packular will try to read packular.conf in the current directory. Use packular config_file to provide another filename.

Sample config file:

[DEFAULT]
# default options apply to all ``target:`` blocks and can be
# overriden on the command line

# you may define a version ID and interpolate it into values below
version = 9c2a5d2096dbb

# source template for index.html
template = index-template.html

# download remote files into these directories
download = true
dir_js = lib
dir_css = lib

# prefix for all URLs inserted into index.html
prefix_js = ./app/
prefix_css = ./app/

# specify default targets for file lists below, default is all targets
javascript = dev,test,prod
css = dev,test,prod
partial = test,prod

# any non reserved options will be passed as context variables when
# rendering the template. they can be used in the template using the
# python dictionory interpolation format e.g. %(custom_favicon)s
custom_favicon = favicon.ico

[target:prod]
index = index-production.html
download = false

# combine list of partials below into template cache file
combine_partial = template-cache.js

# combine all JS/CSS sources into one file
combine_js = production.js
# but include under a different name in the generated HTML
# (allows for running eg. minification on the output of combine_js)
include_js = production-min.js
combine_css = production.css

# overwrite some of the defaults -- the version is set above in [DEFAULT]
prefix_js = http://cdn.example.org/static/%(version)s/js/
prefix_css = http://cdn.example.org/static/%(version)s/css/

# override variable value
custom_favicon = favicon.png

[target:dev]

# index.html generated for this target
index = index-development.html

# empty cache for development
combine_partial = no-template-cache.js

[target:test]
index = index-test.html
combine_partial = template-cache.js

[javascript]

# included in all index.html
test.js

# include in development index.html only
no-template-cache.js = dev

# include in production and testing index.html only
template-cache.js = prod,test

# include in test index.html only
mocks.js = test

# remote resources start with //
//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

[css]
test.css

[partial]
test.html

Command line options:

usage: packular [-h] [-S [KEY=VALUE [KEY=VALUE ...]]] [CONFIG_FILE]

positional arguments:
  CONFIG_FILE           Packular configuration file (default packular.conf)

optional arguments:
      -S [KEY=VALUE [KEY=VALUE ...]]
                        Overwrite config file variables

Example:

packular -S version=`git rev-parse HEAD`

Angular usage:

angular.module('MyApp', ['templatecache']);

packular's People

Contributors

giampaolo avatar grunskis avatar johaness avatar

Watchers

 avatar  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.