Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include gulp
- var gulp = require('gulp');
- // Include plugins
- var nib = require ('nib'); //addon for stylus
- var data = require('gulp-data'); //required for stylus
- var stylus = require('gulp-stylus');
- var browserSync = require('browser-sync').create();
- var concat = require('gulp-concat');
- var uglifycss = require('gulp-uglifycss');
- var sass = require('gulp-sass');
- // var koutoSwiss = require( "kouto-swiss" );
- // Setup Tasks
- // Stylus
- gulp.task('stylus', function () {
- var stream = gulp.src(['stylus/**.styl', '!stylus/_*.styl'])
- .pipe(stylus({
- compress: true,
- use: nib()
- }))
- .on('error', onError)
- .pipe(gulp.dest('css'));
- return stream;
- });
- // Sass / Scss
- gulp.task('sass', function () {
- return gulp.src(['sass/**/*.scss', '!sass/**/_*.scss'])
- .pipe(sass.sync().on('error', sass.logError))
- .pipe(gulp.dest('css'));
- });
- // Concatinating CSS
- gulp.task('concat',['stylus'], function(cb) {
- var stream = gulp.src(["css/**.css",
- "!css/app.css",
- "!css/foundation.css",
- "!css/foundation.min.css",
- "!css/master.css",
- "css/global.css"])
- .pipe(concat('master.css'))
- .pipe(gulp.dest('css'));
- return stream;
- });
- // Uglify CSS
- gulp.task('uglifycss',['concat'], function () {
- var stream = gulp.src('css/master.css')
- .pipe(uglifycss({
- "maxLineLen": 80,
- "uglyComments": true,
- }))
- .pipe(gulp.dest('css'));
- return stream;
- });
- //Browser Sync setup
- // Static server
- var PHPFiles = './*.php'; // Path to all PHP files.
- var reload = browserSync.reload; // For manual browser reload.
- gulp.task('browser-sync', function() {
- browserSync.init({
- proxy: "localhost/flex/"
- });
- gulp.watch(['stylus/*.styl','sass/**/*.scss','./*.html', 'gulpfile.js'], ['processCSS']).on('change', browserSync.reload);
- // gulp.watch('./*.html').on('change', browserSync.reload);
- gulp.watch(PHPFiles, reload); //Reloads on PHP changes
- });
- // Run tasks
- gulp.task('default', ['stylus','sass','concat','uglifycss','browser-sync']);
- gulp.task('processCSS', ['stylus','sass','concat','uglifycss']);
- // Error handling
- function onError(err) {
- console.log(err);
- this.emit('end');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement