This repository has been archived by the owner on Jul 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·122 lines (109 loc) · 2.82 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
var gulp = require('gulp');
var cssimport = require('gulp-cssimport');
var cssnano = require('gulp-cssnano');
var rollup = require('rollup-stream');
var source = require('vinyl-source-stream');
var babel = require('rollup-plugin-babel');
var resolve = require('rollup-plugin-node-resolve');
var commonjs = require('rollup-plugin-commonjs');
var sourcemaps = require('rollup-plugin-sourcemaps');
var replace = require('rollup-plugin-replace');
var json = require('rollup-plugin-json');
var builtins = require('rollup-plugin-node-builtins');
var rootImport = require('rollup-plugin-root-import');
var globals = require('rollup-plugin-node-globals');
var inline = require('gulp-inline');
var uglify = require('rollup-plugin-uglify-es');
var cssfont64 = require('gulp-cssfont64');
/***
End main config options
***/
gulp.task('bundle-css', function() {
return gulp
.src('./src/styles/index.css')
.pipe(cssimport())
.pipe(cssnano())
.pipe(gulp.dest('./public/css'));
});
// gulp.task('fonts', function () {
// return gulp
// .src('./fonts/*.*')
// .pipe(cssfont64())
// .pipe(gulp.dest('./fonts64/'));
// })
var cache;
gulp.task('bundle-js', function(cb) {
return rollup({
input: './src/index.js',
cache: cache,
format: 'umd',
plugins: [
babel({
ignore: ['src/vendor/**', 'node_modules/**'],
plugins: ['babel-plugin-lodash']
}),
commonjs({
namedExports: {
'node_modules/react/index.js': [ 'Component' ],
'node_modules/lodash/lodash.js': [
'map',
'get',
'set',
'cloneDeep',
'entries',
'reduce',
'filter',
'chunk',
'flatMap',
'zipWith'
]
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify('development')
}),
rootImport({
root: `${__dirname}/src`,
useEntry: 'prepend',
extensions: '.js'
}),
json(),
globals(),
builtins(),
resolve({
browser: true,
}),
sourcemaps(),
// uglify(),
]
}).on('bundle', function(bundle) {
if (!cache) {
cache = bundle;
}
})
.on('error', function(e){
console.log(e);
cb();
})
.pipe(source('index.js'))
.pipe(gulp.dest('./public/js/'))
.on('end', cb);
});
gulp.task('inline', function () {
return gulp
.src('./public/index.html')
.pipe(inline({
base: './public/',
disabledTypes: ['svg', 'img'],
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', gulp.series(
// 'fonts',
gulp.parallel('bundle-js', 'bundle-css'),
'inline',
));
gulp.task('watch', gulp.series('default', function() {
gulp.watch('src/**/*.js', gulp.parallel('bundle-js'));
gulp.watch('src/**/*.css', gulp.parallel('bundle-css'));
}));