Created
February 25, 2015 20:11
-
-
Save anonymous/7359382532e332573192 to your computer and use it in GitHub Desktop.
Gulp: Less + Prefixing + Minify
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
// Initialize ... (just an example) | |
@import "components/normalize"; | |
@import "variables"; | |
@import "mixins"; | |
// Load optional components |
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 gulp = require('gulp'); | |
var plugins = { | |
less: require('gulp-less'), | |
cleancss: require('less-plugin-clean-css'), | |
autoprefix: require('less-plugin-autoprefix') | |
}; | |
var paths = { | |
origin: { | |
less: { | |
base: './less/foo.less', | |
importPaths: [ | |
'./less', | |
'./less/components' | |
] | |
} | |
}, | |
destination: { | |
less: './css' | |
} | |
}; | |
gulp.task('less', function() { | |
return gulp.src(paths.origin.less.base) | |
.pipe(plugins.less({ | |
paths: paths.origin.less.importPaths, | |
plugins: [ | |
new plugins.autoprefix({browsers: ["last 10 versions"]}), | |
new plugins.cleancss({advanced: true}) | |
] | |
})) | |
.pipe(gulp.dest(paths.destination.less)); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(paths.origin.less.base, ['less']); | |
gulp.watch(paths.origin.less.importPaths, ['less']); | |
}); | |
gulp.task('default', [ | |
'less', | |
'watch' | |
]); |
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
{ | |
"name": "foo", | |
"description": "bar", | |
"version": "0.0.1", | |
"readme": "No readme data", | |
"repository": {}, | |
"dependencies": {}, | |
"devDependencies": { | |
"gulp": "^3.8.11", | |
"gulp-less": "^3.0.1", | |
"less-plugin-autoprefix": "^1.3.0", | |
"less-plugin-clean-css": "^1.5.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment