markdown Gulp,Stylus,Browsersync,JS Uglify

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Gulp,Stylus,Browsersync,JS Uglify相关的知识,希望对你有一定的参考价值。

```
// Include gulp
var gulp    = require('gulp');
var nib     = require('nib');

// Include Our Plugins
var jshint      = require('gulp-jshint');
var concat      = require('gulp-concat');
var uglify      = require('gulp-uglify');
var rename      = require('gulp-rename');
var stylus      = require('gulp-stylus');
var browserSync = require('browser-sync').create();

// Lint Task
gulp.task('lint', function() {
    return gulp.src('js/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

// Concatenate & Minify JS
gulp.task('scripts', function() {
    return gulp.src('js/*.js')
        .pipe(concat('all.js'))
        .pipe(gulp.dest('dist'))
        .pipe(rename('all.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dist/js'));
});

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch('js/*.js', ['lint', 'scripts']);
    gulp.watch('css/**/*.styl', ['stylus']);
    gulp.watch('./**/*.php', browserSync.reload);
    gulp.watch('css/**/*.styl', browserSync.reload);
});

// Include css
gulp.task('stylus', function() {
    return gulp.src('./css/**/*.styl')
        .pipe(stylus({
            'include css': true,
            'use': nib(),
            'compress': true
        }))
        .pipe(gulp.dest('./dist/css'));
});

// Browsersync
gulp.task('browser-sync', function() {
    dev: {
        browserSync.init({
            proxy: "endlesschapter.localtest"
        });
    }
});

// Default Task
gulp.task('default', ['lint', 'stylus', 'scripts', 'browser-sync', 'watch']);
gulp.task('dev', ['lint', 'stylus', 'scripts', 'browser-sync', 'watch']);
```

以上是关于markdown Gulp,Stylus,Browsersync,JS Uglify的主要内容,如果未能解决你的问题,请参考以下文章

前端进阶之路-二如何用gulp搭建一套web前端开发框架

Gulp Front Matter + Markdown 通过 Nunjucks

markdown [修正] Gulp问题修复

markdown NPM Bootstrap Gulp安装

markdown GULP

markdown Gulp安装在CentOS6上。