-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpFile.js
142 lines (105 loc) · 3.67 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var cssnano = require('gulp-cssnano');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var sassGlob = require('gulp-sass-glob');
var gulpMerge = require('gulp-merge')
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var babelify = require('babelify');
var THEME_DIR = "./",
ASSETS_DIR = THEME_DIR + 'assets/',
SITE_STYLES_INIT_FILE = ASSETS_DIR + "scss/site.scss",
SITE_SCRIPTS_INIT_FILE = ASSETS_DIR + 'js/site.js',
VENDOR_STYLES_INIT_FILE = ASSETS_DIR + "scss/vendor.scss",
DESTINATION_FOLDER = ASSETS_DIR + "dist/",
DESTINATION_VENDOR_STYLES = 'vendor.css',
INCLUDE_DIRS = [
'node_modules/'
]
;
sass.compiler = require('node-sass');
gulp.task('foundation', function () {
return gulp.src(ASSETS_DIR + 'scss/vendor/foundation-custom.scss')
.pipe(sass({includePaths: ['node_modules/foundation-sites/scss', 'node_modules']}).on('error', sass.logError))
//.pipe(sourcemaps.init())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
//.pipe(sourcemaps.write())
.pipe(gulp.dest(DESTINATION_FOLDER))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(DESTINATION_FOLDER));
});
gulp.task('vendor-styles', function () {
return gulp.src(VENDOR_STYLES_INIT_FILE)
.pipe(sass({includePaths: INCLUDE_DIRS}).on('error', sass.logError))
//.pipe(sourcemaps.init())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
//.pipe(sourcemaps.write())
.pipe(gulp.dest(DESTINATION_FOLDER + DESTINATION_VENDOR_STYLES))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(DESTINATION_FOLDER));
});
// gulp.task('bundle-js', function() {
// var bundleStream = browserify({
// entries: SITE_SCRIPTS_INIT_FILE
// }) .transform('babelify', {
// // https://babeljs.io/docs/en/env/
// presets: ['@babel/preset-env']
// }).bundle();
// bundleStream.pipe(source('vendor-bun.js'))
// .pipe(gulp.dest('./assets'));
// });
// gulp.task('js', function() {
// return browserify({
// entries: 'assets/js/site.js',
// debug: true,
// extensions: ['.js', '.json', '.es6'],
// paths: ['node_modules/foundation-sites/dist/js/plugins']
// })
// .transform(babelify)
// .bundle()
// .pipe(source('vendor.js'))
// .pipe(gulp.dest('assets'));
// })
gulp.task('js', function() {
return browserify({
entries: SITE_SCRIPTS_INIT_FILE,
debug: true,
extensions: ['.js', '.json', '.es6'],
paths: INCLUDE_DIRS
})
.transform(babelify)
.bundle()
.pipe(source('all.js'))
.pipe(gulp.dest(DESTINATION_FOLDER));
});
gulp.task('sass', function () {
return gulp.src(SITE_STYLES_INIT_FILE)
.pipe(sourcemaps.init())
.pipe(sassGlob())
.pipe(sass({includePaths: ['node_modules/foundation-sites/scss', 'node_modules']}).on('error', sass.logError))
.pipe(rename('site.css'))
.pipe(gulp.dest(DESTINATION_FOLDER));
});
gulp.task('watch-styles', function () {
return gulp.watch(ASSETS_DIR + 'scss/**/*.scss', gulp.series('sass'));
});
gulp.task('watch-js', function () {
return gulp.watch(ASSETS_DIR + 'js/**/*.js', gulp.series('js'));
});
gulp.task('watch-vendor', function () {
return gulp.watch(ASSETS_DIR + 'vendor/**/*.scss', gulp.series('vendor-styles'));
});
gulp.task('watch', gulp.parallel(['watch-styles', 'watch-js', 'watch-vendor']));
gulp.task('build', gulp.parallel(['foundation', 'js', 'sass']));