-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (59 loc) · 1.71 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var concat = require('gulp-concat');
var minify = require('gulp-minify');
var uglify = require('gulp-uglifyjs');
var nano = require('gulp-cssnano');
var webserver = require('gulp-webserver');
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
gulp.task('css', function () {
var stream = (
gulp.src('./src/css/main.css')
.pipe(sourcemaps.init())
.pipe(postcss([
require("postcss-import")(),
require("postcss-url")(),
require("precss")(),
require("postcss-cssnext")(),
require("postcss-browser-reporter")(),
require("postcss-reporter")()
]))
.pipe(nano())
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: '/src/css/'
}))
.pipe(gulp.dest('./dist/css'))
);
stream.on('error', function (error) {
console.log(error);
});
return stream;
});
gulp.task('default', ['css', 'js', 'watch', 'webserver']);
gulp.task('js', function () {
gulp.src([
'./src/js/main.js',
])
.pipe(uglify('main.js', {
outSourceMap: true,
sourceRoot: '../..',
mangle: false,
compress: {
drop_debugger: false
}
}))
.pipe(gulp.dest('./dist/js'))
});
gulp.task('watch', function () {
gulp.watch('./src/css/*.*', ['css']);
gulp.watch('./src/js/*.js', ['js']);
});