-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
71 lines (57 loc) · 1.49 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
var gulp = require('gulp');
var serve = require('gulp-serve');
var less = require('gulp-less');
var path = require('path');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const json = require('rollup-plugin-json');
var dependencies = [];
gulp.task('less', () => {
return gulp.src('./src/**/*.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
}))
.pipe(gulp.dest('./build/css'));
});
const plugins = [
nodeResolve({
preferBuiltins: false
}), commonjs(), json(), babel()
];
gulp.task('build', () => {
return rollup.rollup({
input: './src/index.js',
plugins
}).then(bundle => {
return bundle.write({
file: './dist/app.js',
format: 'iife',
name: 'mosrings',
sourcemap: false
});
});
});
gulp.task('watch', () => {
return rollup.watch({
input: './src/index.js',
plugins,
output: {
file: './dist/app.js',
format: 'iife',
name: 'mosrings',
sourcemap: true
}
}).on('end', (a) => console.log(a));
});
gulp.task('scripts', () => bundleApp(true));
gulp.task('serve', serve({
root: ['.'],
port: 3001
}));
gulp.task('watch-less', function () {
return gulp.watch('./src/**/*.less', gulp.series('less'));
});
gulp.task('default', gulp.parallel('watch', 'watch-less', 'serve'));
gulp.task('production', gulp.parallel('build', 'less'));