1 | var gulp = require('gulp');
|
2 | var less = require('gulp-less');
|
3 | var browserSync = require('browser-sync').create();
|
4 | var header = require('gulp-header');
|
5 | var cleanCSS = require('gulp-clean-css');
|
6 | var rename = require("gulp-rename");
|
7 | var uglify = require('gulp-uglify');
|
8 | var pkg = require('./package.json');
|
9 |
|
10 |
|
11 | var banner = ['/*!\n',
|
12 | ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
|
13 | ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
|
14 | ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
|
15 | ' */\n',
|
16 | ''
|
17 | ].join('');
|
18 |
|
19 |
|
20 | gulp.task('less', function() {
|
21 | return gulp.src('less/sb-admin-2.less')
|
22 | .pipe(less())
|
23 | .pipe(header(banner, { pkg: pkg }))
|
24 | .pipe(gulp.dest('dist/css'))
|
25 | .pipe(browserSync.reload({
|
26 | stream: true
|
27 | }))
|
28 | });
|
29 |
|
30 |
|
31 | gulp.task('minify-css', ['less'], function() {
|
32 | return gulp.src('dist/css/sb-admin-2.css')
|
33 | .pipe(cleanCSS({ compatibility: 'ie8' }))
|
34 | .pipe(rename({ suffix: '.min' }))
|
35 | .pipe(gulp.dest('dist/css'))
|
36 | .pipe(browserSync.reload({
|
37 | stream: true
|
38 | }))
|
39 | });
|
40 |
|
41 |
|
42 | gulp.task('js', function() {
|
43 | return gulp.src(['js/sb-admin-2.js'])
|
44 | .pipe(header(banner, { pkg: pkg }))
|
45 | .pipe(gulp.dest('dist/js'))
|
46 | .pipe(browserSync.reload({
|
47 | stream: true
|
48 | }))
|
49 | })
|
50 |
|
51 |
|
52 | gulp.task('minify-js', ['js'], function() {
|
53 | return gulp.src('js/sb-admin-2.js')
|
54 | .pipe(uglify())
|
55 | .pipe(header(banner, { pkg: pkg }))
|
56 | .pipe(rename({ suffix: '.min' }))
|
57 | .pipe(gulp.dest('dist/js'))
|
58 | .pipe(browserSync.reload({
|
59 | stream: true
|
60 | }))
|
61 | });
|
62 |
|
63 |
|
64 | gulp.task('copy', function() {
|
65 | gulp.src(['bower_components/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
|
66 | .pipe(gulp.dest('vendor/bootstrap'))
|
67 |
|
68 | gulp.src(['bower_components/bootstrap-social/*.css', 'bower_components/bootstrap-social/*.less', 'bower_components/bootstrap-social/*.scss'])
|
69 | .pipe(gulp.dest('vendor/bootstrap-social'))
|
70 |
|
71 | gulp.src(['bower_components/datatables/media/**/*'])
|
72 | .pipe(gulp.dest('vendor/datatables'))
|
73 |
|
74 | gulp.src(['bower_components/datatables-plugins/integration/bootstrap/3/*'])
|
75 | .pipe(gulp.dest('vendor/datatables-plugins'))
|
76 |
|
77 | gulp.src(['bower_components/datatables-responsive/css/*', 'bower_components/datatables-responsive/js/*'])
|
78 | .pipe(gulp.dest('vendor/datatables-responsive'))
|
79 |
|
80 | gulp.src(['bower_components/flot/*.js'])
|
81 | .pipe(gulp.dest('vendor/flot'))
|
82 |
|
83 | gulp.src(['bower_components/flot.tooltip/js/*.js'])
|
84 | .pipe(gulp.dest('vendor/flot-tooltip'))
|
85 |
|
86 | gulp.src(['bower_components/font-awesome/**/*', '!bower_components/font-awesome/*.json', '!bower_components/font-awesome/.*'])
|
87 | .pipe(gulp.dest('vendor/font-awesome'))
|
88 |
|
89 | gulp.src(['bower_components/jquery/dist/jquery.js', 'bower_components/jquery/dist/jquery.min.js'])
|
90 | .pipe(gulp.dest('vendor/jquery'))
|
91 |
|
92 | gulp.src(['bower_components/metisMenu/dist/*'])
|
93 | .pipe(gulp.dest('vendor/metisMenu'))
|
94 |
|
95 | gulp.src(['bower_components/morrisjs/*.js', 'bower_components/morrisjs/*.css', '!bower_components/morrisjs/Gruntfile.js'])
|
96 | .pipe(gulp.dest('vendor/morrisjs'))
|
97 |
|
98 | gulp.src(['bower_components/raphael/raphael.js', 'bower_components/raphael/raphael.min.js'])
|
99 | .pipe(gulp.dest('vendor/raphael'))
|
100 |
|
101 | })
|
102 |
|
103 |
|
104 | gulp.task('default', ['minify-css', 'minify-js', 'copy']);
|
105 |
|
106 |
|
107 | gulp.task('browserSync', function() {
|
108 | browserSync.init({
|
109 | server: {
|
110 | baseDir: ''
|
111 | },
|
112 | })
|
113 | })
|
114 |
|
115 |
|
116 | gulp.task('dev', ['browserSync', 'less', 'minify-css', 'js', 'minify-js'], function() {
|
117 | gulp.watch('less/*.less', ['less']);
|
118 | gulp.watch('dist/css/*.css', ['minify-css']);
|
119 | gulp.watch('js/*.js', ['minify-js']);
|
120 |
|
121 | gulp.watch('pages/*.html', browserSync.reload);
|
122 | gulp.watch('dist/js/*.js', browserSync.reload);
|
123 | });
|