-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
127 lines (117 loc) · 2.85 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* gulp modules
*/
const gulp = require('gulp');
const buble = require('gulp-buble');
const rollup = require('gulp-rollup');
const stylus = require('gulp-stylus');
const rename = require("gulp-rename");
const uglify = require('gulp-uglify');
const plumber = require('gulp-plumber');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
/**
* browser Sync
*/
const browserSync = require('browser-sync');
const reload = browserSync.reload;
/**
* Scripts task
*/
gulp.task('scripts', function () {
gulp.src('./src/js/**/*.js')
.pipe(plumber())
.pipe(rollup({
rollup: require('rollup'),
entry: './src/js/focus.js',
format: 'umd',
moduleName: 'Focus'
}))
.pipe(buble())
.pipe(rename({
basename: "focus",
suffix: "",
extname: ".js"
}))
.pipe(gulp.dest('./dist/js'))
.pipe(reload({stream: true}));
});
/**
* Styles task
*/
gulp.task('styles', function () {
gulp.src('./src/stylus/app.styl')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(rename({
basename: "focus",
suffix: "",
extname: ".css"
}))
.pipe(autoprefixer('last 5 version'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/css'))
.pipe(reload({stream: true}));
});
/**
* Production scripts task
*/
gulp.task('production:scripts', () => {
gulp.src('./src/**/*.js')
.pipe(rollup({
rollup: require('rollup'),
entry: './src/js/focus.js',
format: 'umd',
moduleName: 'Focus'
}))
.pipe(buble())
.pipe(rename({
basename: "focus",
suffix: ".min",
extname: ".js"
}))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
/**
* production styles task
*/
gulp.task('production:styles', () => {
gulp.src('./src/stylus/app.styl')
.pipe(stylus({
compress: true
}))
.pipe(rename({
basename: "focus",
suffix: ".min",
extname: ".css"
}))
.pipe(gulp.dest('./dist/css'));
})
/**
* production task
*/
gulp.task('production', ['styles', 'scripts', 'production:scripts', 'production:styles']);
/**
* Browser-sync task
*/
gulp.task('browser-sync', function () {
browserSync.init({
proxy: "focus.dev/index.html"
});
})
/**
* Watch task
*/
gulp.task('watch', function () {
gulp.watch('./src/js/**/*.js', ['scripts']);
gulp.watch('./src/stylus/**/*.styl', ['styles']);
gulp.watch('./**/*.html', function () {
gulp.src('./**/*.html').pipe(reload({stream: true}));
});
});
/**
* Default task
*/
gulp.task('default', ['styles', 'browser-sync', 'watch']);