generated from graphlab-fr/opensphere-web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·104 lines (89 loc) · 2.5 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
var gulp = require('gulp');
var browserSync = require('browser-sync');
/**
* -----------------------
* Commande par DÉFAUT
* ---
* - Affichage du message "Hello world"
* -----------------------
*/
gulp.task('default', function () {
console.log('Hello world');
});
/**
* -----------------------
* Commandes de GÉNÉRATION
* ---
* - $ gulp css => compliation SCSS -> main.css + prefixage
* - $ gulp js => concatenation JS -> main.js
* -----------------------
*/
// https://www.npmjs.com/package/gulp-sass
var sass = require('gulp-sass');
sass.compiler = require('node-sass');
// https://www.npmjs.com/package/gulp-autoprefixer
var autoprefixer = require('gulp-autoprefixer');
gulp.task('css', function () {
return gulp.src('./dist/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
cascade: false
}))
.pipe(gulp.dest('./assets'))
.pipe(browserSync.reload({
stream: true
}));
});
// https://www.npmjs.com/package/gulp-concat
var concat = require('gulp-concat');
gulp.task('js', function () {
return gulp.src('./dist/scripts/*.js')
.pipe(concat('main.js'))
.pipe(gulp.dest('./assets/'))
.pipe(browserSync.reload({
stream: true
}));
});
/**
* -----------------------
* Commandes de MINIFICATION
* ---
* - $ gulp minify => minification JS et CSS
* -----------------------
*/
https: //www.npmjs.com/package/gulp-clean-css
var minifyCss = require('gulp-clean-css');
gulp.task('minifyCSS', function () {
return gulp.src('./assets/*.css')
.pipe(minifyCss())
.pipe(gulp.dest('./assets/'));
});
// https://www.npmjs.com/package/gulp-minify
var minifyJs = require('gulp-minify');
gulp.task('minifyJS', function () {
return gulp.src('./assets/*.js')
.pipe(minifyJs({
ext: {
src: 'main.js'
}
}))
.pipe(gulp.dest('./assets/'));
});
gulp.task('minify', gulp.series('minifyCSS', 'minifyJS'));
/**
* -----------------------
* Commande d'AUTOMATISATION
* ---
* - $ gulp watch => activation des commandes de GÉNÉRATION
* -----------------------
*/
gulp.task('watch', function () {
gulp.watch('./dist/sass/**/*.scss', gulp.series('css'))
.on('change', function (event) {
console.log('CSS updated');
});
gulp.watch('./dist/scripts/*.js', gulp.series('js'))
.on('change', function (event) {
console.log('JS updated');
});
});