Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Auto-optimization with Express and RequireJS
var express = require('express'),
requirejs = require('requirejs'),
app = module.exports = express.createServer();
app.configure('development', function(){
// Use development version of static files
app.use(express.static(__dirname + '/public'));
app.configure('production', function(){
// Optimize the javascript in the public folder and
// copy it to the public_build folder.
appDir: "public/",
baseUrl: "javascripts",
dir: "public_build",
modules: [
name: "main"
}, function() {
console.log('Successfully optimized javascript');
// Use minified static files
app.use(express.static(__dirname + '/public_build'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.