-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
141 lines (121 loc) · 4.13 KB
/
gulpfile.babel.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import { src, dest, watch, series, parallel } from 'gulp';
import yargs from 'yargs';
import sass from 'gulp-sass';
import cleanCss from 'gulp-clean-css';
import gulpif from 'gulp-if';
import postcss from 'gulp-postcss';
import sourcemaps from 'gulp-sourcemaps';
import autoprefixer from 'autoprefixer';
// import imagemin from 'gulp-imagemin';
import del from 'del';
import named from 'vinyl-named';
import webpack from 'webpack-stream';
import stripdebug from 'gulp-strip-debug';
import terser from 'gulp-terser-js';
import wpPot from "gulp-wp-pot";
import browserSync from "browser-sync";
import concat from "gulp-concat";
import gutil from "gulp-util";
// import deporder from "gulp-deporder";
// import uglify from "gulp-uglify";
// const rename = require('gulp-rename');
// const path = require('path');
const PRODUCTION = yargs.argv.prod;
// const webpack_config = require('./webpack.config.js');
const server = browserSync.create();
export const serve = done => {
server.init({
});
done();
};
export const reload = done => {
server.reload();
done();
};
export const clean = () => del(['dist']);
export const FontCopy = () => {
return src('./src/fonts/*')
.pipe(dest('dist/fonts'));
}
export const cssFontIcon = () => {
return src('./src/sass/bootstrap-icon.scss')
.pipe(gulpif(!PRODUCTION, sourcemaps.init()))
.pipe(sass())
.pipe(gulpif(PRODUCTION, postcss([autoprefixer])))
.pipe(gulpif(PRODUCTION, cleanCss({compatibility: 'ie8'})))
.pipe(gulpif(!PRODUCTION, sourcemaps.write()))
.pipe(dest('./dist/css'))
.pipe(sass({
outputStyle: 'compressed',
// imagePath : images.build,
precision: 3,
errLogToConsole: true
}))
.pipe(concat('bootstrap-icon.min.css'))
.pipe(gulpif(PRODUCTION, postcss([autoprefixer])))
.pipe(gulpif(PRODUCTION, cleanCss({compatibility: 'ie8'})))
.pipe(gulpif(!PRODUCTION, sourcemaps.write()))
.pipe(dest('./dist/css'))
.pipe(gutil.noop())
.pipe(server.stream());
}
export const CssDocs = () => {
return src(['./src/sass/bootstrap.scss','./src/sass/docs.scss'])
.pipe(gulpif(!PRODUCTION, sourcemaps.init()))
.pipe(sass({
outputStyle: 'compressed',
// imagePath : images.build,
precision: 3,
errLogToConsole: true
}))
.pipe(gulpif(PRODUCTION, postcss([autoprefixer])))
.pipe(gulpif(PRODUCTION, cleanCss({compatibility: 'ie8'})))
.pipe(gulpif(!PRODUCTION, sourcemaps.write()))
.pipe(dest('./dist/css'))
.pipe(gutil.noop())
.pipe(server.stream());
}
export const CopyDist = () => {
return src('./dist/**/*')
.pipe(dest('./docs/dist'));
}
export const JsDocs = () =>{
return src('./src/js/docs.js')
.pipe(named())
.pipe(webpack({
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: []
}
}
}
]
},
mode: PRODUCTION ? 'production' : 'development',
devtool: !PRODUCTION ? 'inline-source-map' : false,
output: {
filename: '[name].js'
},
externals: {
jquery: 'jQuery'
},
}))
.pipe(terser())
.pipe(gulpif(PRODUCTION, stripdebug()))
.pipe(dest('./dist/js'));
}
export const watchForChanges = () => {
watch('src/sass/bootstrap-icon.scss', cssFontIcon);
watch('src/sass/docs.scss', CssDocs);
watch('src/js/*.js', JsDocs);
watch('src/fonts/*.{eot,svg,ttf,woff,woff2}', series(FontCopy, reload));
watch("**/*.html", reload);
}
export const dev = series(clean, series(cssFontIcon,CssDocs,FontCopy,JsDocs),serve, watchForChanges,CopyDist);
export const build = series(clean, parallel(cssFontIcon,CssDocs,FontCopy,JsDocs),CopyDist);
export default dev;