Skip to content

Instantly share code, notes, and snippets.

@aw3s0me
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save aw3s0me/1afe0c1932de85255de4 to your computer and use it in GitHub Desktop.

Select an option

Save aw3s0me/1afe0c1932de85255de4 to your computer and use it in GitHub Desktop.
Uglify css with requirejs
http://stackoverflow.com/questions/16901246/how-to-minify-css-files-with-requirejs
#1. Create a style.css file and @import all your other css's into this file.
@import url("css/firstfile.css");
@import url("css/secondfile.css");
#2. Create a build.js file as follows:
({
cssIn: './css/style.css',
out: './css/style.min.css',
optimizeCss: 'default'
})
Using require.js minify this file
r.js -o build.js
Modify your index.html to only include this minified style.min.css file
<link rel="stylesheet" type="text/css" href="css/style.min.css">
//Uglify js files
r.js -o app.build.js
({
appDir: "../",
baseUrl: "scripts",
dir: "../dist",
mainConfigFile: "../scripts/main.js",
name: "main"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment