This repository was archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
120 lines (99 loc) · 3.6 KB
/
gulpfile.js
File metadata and controls
120 lines (99 loc) · 3.6 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
114
115
116
117
118
119
120
const gulp = require('gulp'),
concat = require('gulp-concat'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
gutil = require('gulp-util'),
uglify = require('gulp-uglify'),
browserify = require('browserify'),
watchify = require('watchify'),
assign = require('lodash.assign'),
babelify = require('babelify'),
sourcemaps = require('gulp-sourcemaps'),
clean = require("gulp-clean"),
gulpCopy = require('gulp-copy'),
cleanCss = require("gulp-clean-css");
const servePath = 'dist/public';
const devServePath = 'src/public';
const devCssServePath = devServePath+'/stylesheets/';
const devJsPath = 'src/frontEndJS/dependencies/';
const sourceRoot = 'src';
const jsPath = sourceRoot + '/frontEndJS';
const concatJSFiles = [devJsPath+'jquery-3.2.1.min.js', devJsPath+'googlePieChart.min.js', devJsPath+'fontawesome-all.min.js', devJsPath+'smooth-scroll.min.js',
devJsPath+'bundle.js'];
const concatCSSFiles = [devCssServePath+'bootstrap.min.css', devCssServePath+'animate.min.css', devCssServePath+'base.css', devCssServePath+'mainNav.css',
devCssServePath+'timeline.css', devCssServePath+'footer.css',devCssServePath+'classUtilities.css'];
// add custom browserify options here
const customOpts = {
entries: [jsPath + '/app.js'],
debug: true
};
const opts = assign({}, watchify.args, customOpts);
const b = watchify(browserify(opts)).transform(babelify, { presets: ['es2015'] });
gulp.task('buildJsProd', bundleProd);
gulp.task('buildJs', bundle);
gulp.task('concatCssProd', () => {
return gulp.src(concatCSSFiles)
.pipe(concat('bundle.css'))
.pipe(cleanCss())
.pipe(gulp.dest('dist/public/stylesheets'))
});
gulp.task("moveLargeAssets", () => {
gulp.src('src/public/showcase/*/**')
.pipe(gulp.dest('dist/public/showcase'));
});
gulp.task('buildCssProd', ['concatCssProd'], () => {
return process.exit(0);
});
gulp.task('watchJs', function() {
gulp.watch(['src/frontEndJs/**/*.js'], ['concatScripts']);
});
gulp.task('concatScriptsProd', ['buildJsProd'], () => {
return gulp.src(concatJSFiles)
.pipe(concat('bundle.js'))
.pipe(gulp.dest(servePath+'/js'))
});
gulp.task('concatScripts', ['buildJs'], () => {
return gulp.src(concatJSFiles)
.pipe(concat('bundle.js'))
.pipe(gulp.dest(devServePath+'/js'))
});
// gulp.task('buildSourceMaps', ['concatScripts'], () => {
// return gulp.src(devJsPath+'bundle.js')
// .pipe(sourcemaps.init({ loadMaps: true })) // loads map from browserify file
// .pipe(sourcemaps.write('./')) // writes .map file
// .pipe(gulp.dest(devServePath+'/js'));
// });
gulp.task('build', ['concatScripts'], () => {
return process.exit(0);
});
gulp.task('buildProd', ['concatScriptsProd'], () => {
return process.exit(0);
});
gulp.task('cleanDist', () => {
return gulp.src('dist/*')
.pipe(clean());
});
function bundle() {
if (!b) return console.log('Sorry, something went wrong');
return b.bundle()
// log errors if they happe
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
// optional, remove if you don't need to buffer file contents
.pipe(buffer())
// optional, remove if you dont want sourcemaps
.pipe(sourcemaps.init({ loadMaps: true })) // loads map from browserify file
.pipe(sourcemaps.write('./')) // writes .map file
.pipe(gulp.dest(devJsPath));
}
function bundleProd() {
if (!b) return console.log('Sorry, something went wrong');
return b.bundle()
// log errors if they happe
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
// optional, remove if you don't need to buffer file contents
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(devJsPath));
}