-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
27 lines (24 loc) · 826 Bytes
/
gulpfile.js
File metadata and controls
27 lines (24 loc) · 826 Bytes
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
"use strict";
const gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
htmlreplace = require('gulp-html-replace'),
babel = require('gulp-babel');
gulp.task("js-optimize", () => {
return gulp.src('scripts/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015']
}))
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/scripts'));
});
gulp.task("html-optimize", () => {
return gulp.src('index.html')
.pipe(htmlreplace({"compressed-js": '<script src="scripts/app.js" async></script>'}))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['js-optimize', "html-optimize"]);