-
-
Save pyadav/9cd85931617c96fdf416 to your computer and use it in GitHub Desktop.
Auto-optimization with Express and RequireJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
requirejs.optimize({ | |
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