This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (38 loc) · 1.48 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
const { src, dest, series } = require('gulp')
const fs = require('fs')
const merge = require('merge-stream')
const { dependencies } = require('./package.json')
const css = () => {
const destPath = (process.env.NODE_ENV === 'prod' ? 'public_html/' : '')
+ 'assets/css/'
const tasks = Object.keys(dependencies).reduce((acc, dep) => {
// TODO: check for presence of css folder in dist folder
// TODO: check for existence of *.min.css for each file in dist/css
// TODO: pipe the files to dest('assets/css/')
const srcPath = fs.existsSync(`node_modules/${dep}/dist`) && `node_modules/${dep}/dist`
if (fs.existsSync(`${srcPath}/css`)){
console.log(' srcPath = ' + srcPath + '/css')
acc.push(src(`${srcPath}/css/*.css`)
.pipe(dest(destPath)))
}
return acc
}, [])
return merge(tasks)
}
const js = () => {
const destPath = (process.env.NODE_ENV === 'prod' ? 'public_html/' : '')
+ 'assets/js/'
const tasks = Object.keys(dependencies).reduce((acc, dep) => {
const srcPath = fs.existsSync(`node_modules/${dep}/dist`) && `node_modules/${dep}/dist`
if (fs.existsSync(`${srcPath}/js`)) {
console.log(' srcPath = ' + srcPath + '/js')
acc.push(src(`${srcPath}/js/*.js`)
.pipe(dest(destPath)))
}
return acc
}, [])
return merge(tasks)
}
exports.css = css
exports.js = js
exports.default = series(css, js)