forked from cppsea/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
113 lines (95 loc) · 3.37 KB
/
gulpfile.js
File metadata and controls
113 lines (95 loc) · 3.37 KB
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
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
uglifycss = require('gulp-uglifycss'),
image = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
runSequence = require('run-sequence');
/*
==================================================================
Keep localTesting DISABLED unless you want to use it. With it enabled, gulp will copy the build to distPath.
*/
var packageName = "CPPSea";
var localTesting = true;
var distPath = "D:/xampp/htdocs/" + packageName + "/"; // change this based on where your local copy is
/*
==================================================================
*/
gulp.task('watch', function() {
if(localTesting) {
gulp.watch('src/*.html', function() { runSequence('html', 'html-local'); });
gulp.watch('src/**/*.html', function() { runSequence('inner-html', 'inner-html-local'); });
gulp.watch('src/stylesheets/**/*.scss', function() { runSequence('styles', 'styles-local'); });
gulp.watch('src/media/*', function() { runSequence('images', 'images-local'); });
gulp.watch('src/scripts/*.js', function() { runSequence('scripts', 'scripts-local'); });
} else {
gulp.watch('src/*.html', ['html']);
gulp.watch('src/**/*.html', ['inner-html']);
gulp.watch('src/stylesheets/**/*.scss', ['styles']);
gulp.watch('src/media/*', ['images']);
gulp.watch('src/scripts/*.js', ['scripts']);
}
});
gulp.task('html', function() {
return gulp.src('src/*.html')
.pipe(gulp.dest("."));
});
gulp.task('inner-html', function() {
return gulp.src('src/**/*.html')
.pipe(gulp.dest("."));
});
gulp.task('html-local', function() {
return gulp.src('src/*.html')
.pipe(gulp.dest(distPath));
});
gulp.task('inner-html-local', function() {
return gulp.src('src/**/*.html')
.pipe(gulp.dest(distPath));
});
gulp.task('styles', function() {
return sass('src/stylesheets/compositions/*.scss', {style: 'Expanded'})
.pipe(autoprefixer('last 2 version'))
.pipe(gulp.dest('css/'))
.pipe(rename({suffix: '.min'}))
.pipe(uglifycss({ "max-line-len": 40 }))
.pipe(gulp.dest('css/'));
});
gulp.task('styles-local', function() {
return gulp.src("css/*.css")
.pipe(gulp.dest(distPath + 'css/'));
});
gulp.task('scripts', function() {
return gulp.src('src/scripts/*.js')
.pipe(gulp.dest("scripts/"))
.pipe(concat("main.js"))
.pipe(gulp.dest("scripts/"))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest("scripts/"));
});
gulp.task('scripts-local', function() {
return gulp.src('scripts/*.js')
.pipe(gulp.dest(distPath + 'scripts/'));
});
gulp.task('images', function() {
return gulp.src("src/media/*")
.pipe(image({
pngquant: true,
optipng: true,
zopflipng: true,
advpng: false,
jpegRecompress: true,
jpegoptim: true,
mozjpeg: true,
gifsicle: false,
svgo: false
}))
.pipe(gulp.dest('media/'));
});
gulp.task('images-local', function() {
return gulp.src('media/*')
.pipe(gulp.dest(distPath + 'media/'));
});