Skip to content

Instantly share code, notes, and snippets.

@hettiger
Forked from anonymous/foo.less
Last active August 29, 2015 14:16
Show Gist options
  • Save hettiger/34aadba6ca995e86b869 to your computer and use it in GitHub Desktop.
Save hettiger/34aadba6ca995e86b869 to your computer and use it in GitHub Desktop.
Gulp: Less + Prefixing + Minify
// Initialize ... (just an example)
@import "components/normalize";
@import "variables";
@import "mixins";
// Load optional components
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'
]);
{
"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