-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
60 lines (54 loc) · 1.47 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
const fs = require('fs');
const gulp = require('gulp');
const streamify = require('gulp-streamify');
const rename = require('gulp-rename');
const gutil = require('gulp-util');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const browserify = require('browserify');
const sass = require('node-sass');
const cleanCSS = require('gulp-clean-css');
gulp.task('browserify-bundle', function () {
return browserify({
entries: './src/js/vulcanup.js'
})
.transform('babelify', {
presets: ['es2015']
})
.bundle()
.pipe(source('./src/js/vulcanup.js'))
.pipe(rename({
dirname: '',
basename: 'vulcanup'
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('browserify', ['browserify-bundle'], function () {
return gulp.src('./dist/vulcanup.js')
.pipe(rename({
basename: 'vulcanup.min'
}))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('sass', function () {
// bundle
const result = sass.renderSync({
file: './src/scss/_vulcanup.scss',
outFile: './dist/vulcanup.css'
});
fs.writeFileSync(__dirname +'/dist/vulcanup.css', result.css);
// compress
return gulp.src(['./dist/vulcanup.css'])
.pipe(cleanCSS({
compatibility: 'ie8'
}))
.pipe(rename({
dirname: '',
basename: 'vulcanup.min'
}))
.pipe(gulp.dest('./dist', {
overwrite: true
}));
});
gulp.task('default', ['browserify', 'sass']);