Last active
August 29, 2015 14:16
-
-
Save crueber/2580a215a5af03259a4e to your computer and use it in GitHub Desktop.
connect-assets production setup for heroku
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
prodAssetHelpers = require("./middleware/prod_asset_helpers") | |
if app.get('env') == 'production' | |
app.use express.static(path.join(__dirname, "/../public"), maxAge: constant.one_week) | |
prodAssetHelpers(app, path.join(__dirname, "/../public")) | |
else | |
app.use express.static(path.join(__dirname, "/../public"), maxAge: constant.one_second) | |
app.use connectAssets(paths: [ "public/css", "public/js" ], helperContext: app.locals, build: false) |
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
{ | |
"scripts": { | |
"install": "./node_modules/.bin/connect-assets -i public/js public/css -c styles* application.js -o public/assets -gz" | |
} | |
} |
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
module.exports = (app, asset_path) -> | |
manifest = require asset_path+"/assets/manifest.json" | |
app.locals.js = (file) -> '<script src="/assets/'+manifest.assets[file+'.js']+'"></script>' | |
app.locals.css = (file) -> '<link rel="stylesheet" href="/assets/'+manifest.assets[file+'.css']+'"/>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...because I got tired of a kludged together setup. Keep in mind that the install script has to be customized to your environment. I never got wildcards to work for my less files for some reason, without putting it at the end of the filename. If anyone has any thoughts, I'd welcome them.