Giter Site home page Giter Site logo

sandwich.js's Introduction

sandwich.js

sandwich.js helps you deal with all of your .js files. It allows you to use multiple scripts during development and then will concatenate them ready for deployment. It doesn't do any minification itself, so you can choose the minification tool that best suits you.

client-side usage

Initially you need to include the sandwich.js file in your html via script tags. Then a second script should be included that pulls all your scripts in using sandwich's js function.

<!-- in index.html -->
<script src="sandwich.js" type="text/javascript"></script>
<script src="init.js" type="text/javascript"></script>
/* in init.js */
sandwich
  .js('js/this.js')
  .js('js/that.js');

server-side usage

Server-side you need node.js to execute the concatenation code. You use the same sandwich.js (it is able to detect whether it is being run via node or not). You simply use the -f option to tell it the path to your script that calls sandwich's js function and it will do the rest. In this case we have also used '-b' which sets the base path for the script files, this is sometimes necessary when sandwich.js and html files are not in the same directory.

node pub/js/sandwich.js -b pub/ -f pub/js/init.js

The output will be printed to screen. You can then either pipe to file or to a minifier like uglify as shown below

node pub/js/sandwich.js -b pub/ -f pub/js/init.js | uglifyjs > output.js

sandwich.js's People

Contributors

jakeworrell avatar

Stargazers

Baker avatar  avatar jfrux avatar

Watchers

 avatar James Cloos avatar

sandwich.js's Issues

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.