Last active
December 13, 2015 18:58
-
-
Save toolmantim/4958966 to your computer and use it in GitHub Desktop.
Various configurations to ensure newlines are preserved in minified Javascript files. Fork it and add another language/framework/compressor combination!
This file contains hidden or 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
# Brunch - http://brunch.io/ | |
# | |
# Using uglify-js-brunch - https://github.com/brunch/uglify-js-brunch | |
# | |
# Use the following settings in your Brunch configuration file | |
exports.config = | |
plugins: | |
uglify: | |
output: | |
beautify: true | |
indent_level: 0 |
This file contains hidden or 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
Codekit - http://incident57.com/codekit/ | |
Use the following settings in CodeKit's Preferences: | |
Indentiation: 0 spaces | |
Beautify: on |
This file contains hidden or 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
# Google Closure Compiler | |
# | |
# The only way to get Closure Compiler to include newlines is to use the PRETTY_PRINT option, | |
# but there's no way to supress indentation. The only workaround seems to be removing the | |
# indentation manually. | |
# | |
# Below is an example using the sed command to remove the indentation. | |
java -jar compiler.jar --formatting PRETTY_PRINT [script file path] | sed 's/^ *//' |
This file contains hidden or 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
// Grunt - http://gruntjs.com/ | |
// | |
// Using grunt-contrib-uglify - https://npmjs.org/package/grunt-contrib-uglify | |
// | |
// Set the following uglify.options in your Gruntfile.js | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
uglify: { | |
options: { | |
beautify: { | |
beautify: true, | |
indent_level: 0 | |
} | |
} | |
} | |
}); | |
}; |
This file contains hidden or 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
// Node-minify https://npmjs.org/package/node-minify | |
// | |
// Use one of the following set of options when calling compressor.minify | |
new compressor.minify({ | |
type: 'uglifyjs', | |
options: ['--beautify "indent-level=0"'] | |
}); | |
new compressor.minify({ | |
type: 'yui-js', | |
options: ['--line-break 0'] | |
}); |
This file contains hidden or 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
# Rails 3 asset pipeline - http://rubyonrails.org/ | |
# | |
# Add the following to your config/environments/production.rb | |
# Only run when Uglifier is available (i.e. the :assets bundler group) | |
if defined? Uglifier | |
config.assets.js_compressor = Uglifier.new( | |
output: { | |
# Add new lines | |
beautify: true, | |
# Don't add indentation | |
indent_level: 0 | |
} | |
) | |
end |
This file contains hidden or 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
# Sinatra AssetPack - https://github.com/rstacruz/sinatra-assetpack | |
# | |
# Add the following to your assets configure block | |
js_compression :uglify, | |
output: { | |
# Add new lines | |
beautify: true, | |
# Don't add indentation | |
indent_level: 0 | |
} |
This file contains hidden or 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
// UglifyJS 2 node library - https://github.com/mishoo/UglifyJS2 | |
// | |
// Use the following options when calling UglifyJS.minify | |
var UglifyJS = require("uglify-js"); | |
var result = UglifyJS.minify("[script file path]", { | |
output: { | |
beautify: true, | |
indent_level: 0 | |
} | |
}); | |
console.log(result.code); |
This file contains hidden or 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
# UglifyJS 2 cmd line tool - http://nodejs.org/ https://github.com/mishoo/UglifyJS2 | |
# | |
# Use the following command line options with the uglifyjs command line tool | |
uglifyjs [script file path] --beautify "indent-level=0" |
This file contains hidden or 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
# YUI Compressor - http://yui.github.com/yuicompressor/ | |
# | |
# Use the following command line options with the YUI compressor line tool | |
java -jar yuicompressor.jar --line-break 0 [script file path] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment