-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (54 loc) · 1.89 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
var gulp = require('gulp'),
del = require('del'),
browserSync = require('browser-sync').create(),
plugins = require('gulp-load-plugins')({
camelize: true
});
// configuracion gulpfile.js
global.GULP_CONFIG = require('./gulpconfig');
// Borrar directorio destino ( inicio proyecto )
function clean() {
return del(GULP_CONFIG.destino, {
force: true
});
}
// ### styles
function styles() {
return gulp.src(GULP_CONFIG.styles.origen)
.pipe(plugins.sourcemaps.write({
includeContent: false
}))
.pipe(plugins.sourcemaps.init({
loadMaps: true
}))
.pipe(plugins.sass(GULP_CONFIG.styles.libsass).on('error', plugins.sass.logError))
.pipe(plugins.cssnano(GULP_CONFIG.styles.cssnano))
// .pipe(plugins.concat(GULP_CONFIG.styles.concat))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest(GULP_CONFIG.styles.destino))
.pipe(browserSync.stream());
}
// ### html
function htmls() {
return gulp.src(GULP_CONFIG.htmls.origen)
.pipe(plugins.changed(GULP_CONFIG.htmls.destino))
.pipe(gulp.dest(GULP_CONFIG.htmls.destino));
}
// ### scripts js
function scriptsjs() {
return gulp.src(GULP_CONFIG.scriptsjs.origen)
.pipe(plugins.uglify(GULP_CONFIG.scriptsjs.uglify))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.concat(GULP_CONFIG.scriptsjs.concat))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest(GULP_CONFIG.scriptsjs.destino));
}
// ### watch
function watch() {
browserSync.init(GULP_CONFIG.browsersync);
gulp.watch(GULP_CONFIG.styles.origen, styles);
gulp.watch(GULP_CONFIG.htmls.origen, htmls).on('change', browserSync.reload);
gulp.watch(GULP_CONFIG.scriptsjs.origen, scriptsjs);
}
var construccion = gulp.series(clean, gulp.parallel(htmls, styles, scriptsjs), watch);
gulp.task('default', construccion);