GithubHelp home page GithubHelp logo

node-enchilada's Introduction

enchilada Build Status

serve up your javascript files all wrapped up using browserify. Yum!

var app = express();

// serves up all your javascript files, handling all require() calls
app.use(enchilada(__dirname + '/public'));

// fallback for other static resources
app.use(express.static(__dirname + '/public'));

Now just visit any .js url which maps to a path under /public and the packaged file will be served.

with ingredients

No one likes a stale enchilada. Out in the real world, you want to leverage browser caching for rarely changing files. Imagine that your project uses files like jquery or engine.io, these files don't change as much as your app code. It would be silly to keep sending them with every js file you serve up. Enchilada makes this easy to do.

Just add the proper ingredients and your enchilada will be served up as you requested.

app.use(enchilada({
    src: __dirname + '/public', // location of your js files
    cache: true || false, // default false (use true for production to disable file watching)
    compress: true || false, // default false
    debug: true || false, // default false (enable sourcemap output with bundle)
    watchCallback: function(filename) {}, // optional (use to do something clever, like tell client to reload the page)
    routes: {
        // key is the url route, value is either a file relative to src
        '/js/jquery.js': './js/jquery.js',
        // or a module installed via npm
        '/js/engine.io.js': 'engine.io-client'
    },
    transforms: [ handleify, brfs ]
}));

Now just make sure you load the required scripts before any other js file that might use them.

<!-- load the scripts we know will be used by several files -->
<script src="/js/jquery.js"></script>
<script src="/js/engine.io.js"></script>

<!-- load other js files as you would before -->
<script src="/js/app.js"></script>

examples

See the examples directory for working code you can copy and paste.

install

Install with npm

npm install enchilada

node-enchilada's People

Contributors

defunctzombie avatar marcello3d avatar bcronin avatar

Watchers

Navid Nikpour 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.