-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgulpfile.js
More file actions
123 lines (83 loc) · 3.19 KB
/
gulpfile.js
File metadata and controls
123 lines (83 loc) · 3.19 KB
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
const gulp = require('gulp');
const { parallel } = require('gulp');
const concat = require('gulp-concat');
const clean = require('gulp-clean');
const sass = require('gulp-sass')(require('sass'));
const cleanCSS = require('gulp-clean-css');
const sourcemaps = require('gulp-sourcemaps');
const rename = require('gulp-rename');
const folderPath = __dirname;
const folderName = folderPath.substring(folderPath.lastIndexOf('\\') + 1);
// SCSS ----------------------
const skinScssPath = ['./_src/skin.scss'];
const scssWatchPath = ['./_src/**/*.scss','./opencontent/templates/**/*.scss'];
function buildScss() { // Parse only the Skin.scss file
return gulp.src(skinScssPath)
// 2. Parse SCSS (silence dependency warnings, keep errors)
.pipe(sass.sync({ quietDeps: true }).on('error', sass.logError))
// 4. Compress CSS
.pipe(cleanCSS({ inline: ['none'] }))
// 6. Write minified CSS
.pipe(gulp.dest('./'));
}
// Containers ----------------------
const containerSource = ['_src/containers/**/*.*'];
const containersTarget = ['../../containers/' + folderName];
function copyContainers() {
// 1. clean the DNN Container folder
gulp.src(containersTarget + '**/*.*', {read: false})
.pipe(clean({force: true}));
// 2. Get containers
return gulp.src(containerSource)
// 3. Move to container folder
.pipe(gulp.dest(containersTarget))
;
}
const jsWatchPath = '_src/theme/js/**/*.js'
const jsSource = ['_src/theme/js/menu.js', '_src/theme/js/menu-hover.js', '_src/theme/js/mark-empty-panes.js', '_src/theme/js/scroll-class.js'];
const jsDest = ['vendors/theme/js'];
function jsBundle(cb){
gulp.src(jsSource)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest));
cb();
}
function styleTask(){
buildScss();
}
function getVendors(cb){
// FontAwesome 5 CSS
const faCSS = ['node_modules/@fortawesome/fontawesome-free/css/all.css', '_src/theme/css/FontAwesome-4-shim/v4-shims.min.css']; // Unfortunately the v4 Shim is not available through npm
const faCSSDest = 'vendors/fontawesome/css';
gulp.src(faCSS)
.pipe(gulp.dest(faCSSDest));
// FontAwesome 5 Fonts
const faFonts = ['node_modules/@fortawesome/fontawesome-free/webfonts/*'];
const faFontsDest = 'vendors/fontawesome/webfonts';
gulp.src(faFonts)
.pipe(gulp.dest(faFontsDest));
// Bootstrap JS
const bootsJS = ['node_modules/bootstrap/dist/js/*'];
const bootsJSDest = 'vendors/bootstrap/js';
gulp.src(bootsJS)
.pipe(gulp.dest(bootsJSDest));
const bootsIcons = ['node_modules/bootstrap-icons/icons/*.*'];
const bootsIconsDest = ['assets/icons/bs'];
gulp.src(bootsIcons)
.pipe(gulp.dest(bootsIconsDest));
cb();
}
// Watch task: watch SCSS and JS files for changes
// If any change, run scss and js tasks simultaneously
function watchTask(){
gulp.watch(containerSource, { delay: 1000 }, copyContainers);
gulp.watch(scssWatchPath, buildScss);
gulp.watch(jsWatchPath, jsBundle);
}
exports.copyContainers = copyContainers;
exports.buildScss = buildScss;
exports.style = styleTask;
exports.jsbundle = jsBundle;
exports.vendors = getVendors;
exports.setup = parallel(getVendors, copyContainers, buildScss, jsBundle);
exports.default = watchTask;