-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (73 loc) · 2.24 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
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const rollup = require('rollup');
const resolve = require('rollup-plugin-node-resolve');
const typescript = require('rollup-plugin-typescript');
const uglify = require('gulp-terser');
const cleanCSS = require('gulp-clean-css');//To Minify CSS files
const del = require('del');
const logSymbols = require('log-symbols'); //For Symbolic Console logs :) :P
const { argv } = require('yargs');
const isProduction = (argv.production === undefined) ? false : true;
function styles() {
var tailwindcss = require('tailwindcss');
return gulp.src('styles/styles.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
tailwindcss('./tailwind.config.js'),
require('autoprefixer'),
]))
.pipe(gulpif(isProduction, cleanCSS({compatibility: 'ie8'})))
.pipe(rename("output.css"))
.pipe(gulp.dest('./public/dist'));
}
function scripts() {
return gulp.src('scripts/**/*.js')
.pipe(concat("output.js"))
.pipe(gulpif(isProduction, uglify()))
.pipe(gulp.dest('./public/dist'));
}
async function buildLitScript() {
const bundle = await rollup
.rollup({
input: ['lit/lit-main.js'],
output: {
file: 'public/dist/lit_index.js',
format: 'es',
sourcemap: true
},
plugins: [
resolve(),
typescript()
]
});
return bundle.write({
file: './public/dist/lit_index.js',
format: 'umd',
name: 'library',
sourcemap: true
});
}
function clean() {
return del("./public/dist");
}
function buildFinish(done) {
console.log("\n\t" + logSymbols.info,`Build is complete.\n`);
done();
}
exports.build = gulp.series(
clean,
gulp.parallel(styles, scripts, buildLitScript),
buildFinish
)
exports.watch = function() {
gulp.watch(['lit/**/*.*', 'styles/**/*.scss'], gulp.series(
clean,
gulp.parallel(styles, scripts, buildLitScript),
buildFinish
));
}