-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
72 lines (66 loc) · 1.79 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
const concat = require('gulp-concat');
const terser = require('gulp-terser');
const sourcemaps = require('gulp-sourcemaps');
const {src, dest} = require('gulp');
const minify = require('gulp-minify');
const {watch} = require('gulp');
const concatCss = require('gulp-concat-css');
const sass = require('gulp-sass')(require('sass'));
/**
* Theme Path
*/
const baseThemePath = './local_packages/psi/';
/**
* all Js Files
*
* the order of explicit added filenames is important
* if you also use a *-selector the file will not be included twice
*
* @type {string[]}
*/
const baseJsPath = [
baseThemePath + 'Resources/Private/JavaScript/*.js',
];
/**
* JS compiler
*
* @type {string[]}
*/
function scripts() {
return src(baseJsPath)
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
.pipe(terser())
.pipe(sourcemaps.write('.'))
.pipe(minify({
ext: {
min: '.min.js'
},
ignoreFiles: ['-min.js']
}))
.pipe(dest(baseThemePath + 'Resources/Public/JavaScript/'));
}
exports.scripts = scripts;
/**
* SCSS compiler
*
* @type {string[]}
*/
const baseSrcFile = baseThemePath + 'Resources/Private/Scss/main.scss';
function styles() {
return src(baseSrcFile)
.pipe(sass())
.pipe(sourcemaps.init())
.pipe(concatCss('style.css'))
.pipe(minify())
.pipe(sourcemaps.write('.'))
.pipe(dest(baseThemePath + 'Resources/Public/Css/'))
}
exports.styles = styles;
/**
* Assets Watcher
*/
exports.watch = function () {
watch(baseThemePath + 'Resources/Private/Scss/**/*.scss', styles);
watch(baseThemePath + 'Resources/Private/JavaScript/**/*.js', scripts);
};