Created
October 27, 2015 01:36
-
-
Save hamaluik/927445db8af221575d89 to your computer and use it in GitHub Desktop.
Flow hook to minify the resulting javascript code (stores it in {{app.name}}.min.js).
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
// ./hooks/minify.js | |
var UglifyJS = require("uglify-js"); // run "npm install uglify-js" in the hooks directory first! | |
var fs = require('fs'); | |
exports.hook = function(flow, done) { | |
var basePath = flow.project.project.app.output + '/web/' + flow.project.project.app.name; | |
var result = UglifyJS.minify(basePath + '.js', { | |
mangle: true // set to false if you run into issues | |
}); | |
fs.writeFile(basePath + '.min.js', result.code, function(err) { | |
if(err) console.log(err); | |
done(); | |
}) | |
} |
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
// ./project.flow | |
{ | |
project: { | |
// ... | |
build: { | |
// ... | |
post: { | |
priority: 1, | |
name: 'minify', | |
desc: 'minify the resulting javascript using uglifyjs', | |
script: './hooks/minify.js' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment