-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgulpfile.js
98 lines (79 loc) · 2.77 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
const { src, dest, series } = require('gulp');
const uglify = require('gulp-uglify');
const less = require('gulp-less');
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const webpack = require('webpack-stream');
const copy = require('gulp-copy');
const { createModule } = require('./gulp-tasks/createModule');
function buildJS() {
return src('./src/classes/FancyProductDesigner.js')
.pipe(webpack({
mode: 'production',
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: "defaults" }]
],
plugins: ["@babel/plugin-transform-private-methods"]
}
}
},
{
test: /\.less$/,
use: [
"style-loader",
"css-loader",
"less-loader"
]
},
{
test: /\.html$/i,
loader: "html-loader",
},
]
}
}))
.pipe(concat('FancyProductDesigner.js'))
.pipe(dest('dist/js/'));
}
function minifyJS() {
return src(['./dist/js/FancyProductDesigner.js'])
.pipe(uglify())
.pipe(concat('FancyProductDesigner.min.js'))
.pipe(dest('dist/js/'));
}
function buildVendorCSS() {
return src(['./src/vendor/css/*.css', './src/vendor/FontFPD/style.css'])
.pipe(cleanCSS())
.pipe(concat('vendor.css'))
.pipe(dest('dist/css/'));
}
function copyFontFiles() {
return src('./src/vendor/FontFPD/fonts/*.*')
.pipe(copy('dist/css/fonts/', { prefix: 4 }))
}
function buildCSS() {
return src('./src/ui/less/main.less')
.pipe(less())
.pipe(cleanCSS())
.pipe(concat('FancyProductDesigner.css'))
.pipe(dest('./dist/css/'));
}
function combineCSS() {
return src(['./dist/css/vendor.css', './dist/css/FancyProductDesigner.css'])
.pipe(concat('FancyProductDesigner.min.css'))
.pipe(dest('dist/css/'));
}
exports.buildJS = buildJS;
exports.minifyJS = minifyJS;
exports.buildCSS = buildCSS;
exports.buildVendors = series(buildVendorCSS, copyFontFiles);
exports.default = series(buildVendorCSS, copyFontFiles, buildJS, minifyJS, buildCSS, combineCSS);
exports.createModule = createModule;