-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgulpfile.js
96 lines (87 loc) · 2.65 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
// Grab our gulp packages
const concat = require('gulp-concat'),
cleanCSS = require('gulp-clean-css');
gulp = require('gulp'),
merge = require('merge-stream'),
rename = require('gulp-rename'),
rollup = require('gulp-better-rollup'),
sourcemaps = require('gulp-sourcemaps'),
terser = require('gulp-terser'),
sassGlob = require('gulp-sass-glob'),
size = require('gulp-size'),
headerfooter = require('gulp-headerfooter');
const { sass } = require("@mr-hope/gulp-sass");
gulp.task('build:styles', function () {
return gulp.src(['components/**/*.scss', 'css/niui-core.scss'])
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(concat('niui.css'))
.pipe(cleanCSS())
.pipe(rename(function (path) {
path.extname = ".min.css"
}))
.pipe(sourcemaps.write('.', {
mapFile: function (mapFilePath) {
return mapFilePath.replace('.css.map', '.css.map');
}
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build:styles_wp', function () {
return gulp.src(['components/**/*.scss', 'css/niui-core.scss', 'css/niui-wp.scss'])
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(concat('niui-wp.css'))
.pipe(cleanCSS())
.pipe(rename(function (path) {
path.extname = ".min.css"
}))
.pipe(sourcemaps.write('.', {
mapFile: function (mapFilePath) {
return mapFilePath.replace('.css.map', '.css.map');
}
}))
.pipe(gulp.dest('niui-wp'));
});
gulp.task('build:script_module', function() {
return gulp.src(['components/**/*.js'])
.pipe(sourcemaps.init())
.pipe(rollup({}, { format: 'es', strict: false}))
.pipe(concat('niui.js'))
.pipe(headerfooter.header('js/niui-core.js'))
.pipe(headerfooter.footer('js/niui-tail.js'))
.pipe(sourcemaps.write('.', {
mapFile: function(mapFilePath) {
return mapFilePath.replace('.js.map', '.js.map');
}
}))
.pipe(gulp.dest('js'));
});
gulp.task('build:script_min', function() {
return gulp.src(['js/niui.js'])
.pipe(sourcemaps.init())
.pipe(rollup({}, { format: 'es', strict: false}))
.pipe(headerfooter.footer(';window.nui = nui;'))
.pipe(terser())
.pipe(rename(function(path) {
path.extname = ".min.js"
}))
.pipe(sourcemaps.write('.', {
mapFile: function(mapFilePath) {
return mapFilePath.replace('.js.map', '.js.map');
}
}))
.pipe(gulp.dest('dist'));
});
gulp.task('size:css', function () {
return gulp.src(['./dist/niui.min.css'])
.pipe(size({gzip: true, title: 'CSS', showFiles: true}))
.pipe(gulp.dest('dist'));
});
gulp.task('size:js', function () {
return gulp.src(['./dist/niui.min.js'])
.pipe(size({gzip: true, title: 'JS', showFiles: true}))
.pipe(gulp.dest('dist'));
});