-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
91 lines (83 loc) · 2.63 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
/**
* Created by bclincy on 5/31/17.
*/
const gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var gulpif = require('gulp-if');
var minify = require('gulp-clean-css');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var config = {
assetsDir: 'src/AppBundle/Resources/assets',
bowerDir: 'vendor/bower_components',
production: !!util.env.production,
sourceMaps: !util.env.production,
webDir: 'web'
};
var app = {};
app.addStyle = function (path, filename) {
gulp.src(path)
.pipe(plumber())
.pipe(gulpif(config.sourceMaps, sourcemaps.init()))
.pipe(sass())
.pipe(gulpif(config.production, minify()))
.pipe(autoprefixer())
.pipe(concat(filename))
.pipe(gulpif(config.sourceMaps, sourcemaps.write('.')))
.pipe(gulp.dest('web/css/'))
};
app.addscripts = function (path, filename) {
return gulp.src(path)
.pipe(plumber())
.pipe(gulpif(config.sourceMaps, sourcemaps.init()))
.pipe(concat(filename))
.pipe(gulpif(config.production, uglify()))
.pipe(gulpif(config.sourceMaps, sourcemaps.write('.')))
.pipe(gulp.dest('web/js'));
}
app.copy = function(srcFiles, outputDir){
console.log(srcFiles);
gulp.src(srcFiles)
.pipe(gulp.dest(outputDir));
}
//Style
gulp.task('styles', function(){
app.addStyle([
config.assetsDir + '/sass/app.scss',
config.bowerDir+'/font-awesome/css/font-awesome.css'
], 'default.css');
app.addStyle([
config.assetsDir + '/sass/carousel.scss'
], 'carousel.css')
})
//font
gulp.task('fonts', function (){
app.copy(config.bowerDir+'/font-awesome/fonts/**/', config.webDir+'/fonts/');
app.copy(config.bowerDir+'/bootstrap-sass/assets/fonts/bootstrap/**/', config.webDir+'/fonts/bootstrap');
})
// Clean
gulp.task('clean', function () {
return gulp.src(['web/css', 'web/scripts'], { read: false }).pipe($.clean());
});
//Script
gulp.task('scripts', function(){
app.addscripts([
config.bowerDir+'/jquery/dist/jquery.js',
config.bowerDir+'/bootstrap-sass/assets/javascripts/bootstrap.js',
config.assetsDir+'/js/**/*.js'
], 'main.js');
});
//default
gulp.task('default',['styles', 'scripts'], function(){
console.log('hello world');
})
//Watch
gulp.task('watch', function() {
console.log('starting watch!');
gulp.watch(config.assetsDir+'/sass/**/*.scss', ['styles']);
gulp.watch(config.assetsDir+'/js/**/*.js', ['scripts']);
});