forked from tolafandpro/metrosoftpr1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod.js
44 lines (38 loc) · 1.46 KB
/
prod.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
const path = require('path');
const { src, dest, series } = require('gulp');
const replace = require('gulp-replace');
const useref = require('gulp-useref');
module.exports = conf => {
// Copy templatePath html files and assets to buildPath
// -------------------------------------------------------------------------------
const prodCopyTask = function () {
return src(`${templatePath}/**/*.html`)
.pipe(dest(buildPath))
.pipe(src('assets/**/*'))
.pipe(dest(`${buildPath}/assets/`));
};
// Rename assets path
// -------------------------------------------------------------------------------
const prodRenameTasks = function () {
return src(`${buildPath}/*.html`)
.pipe(replace('../../assets', 'assets'))
.pipe(dest(buildPath))
.pipe(src(`${buildPath}/assets/**/*`))
.pipe(replace('../../assets', 'assets'))
.pipe(dest(`${buildPath}/assets/`));
};
// Combine js vendor assets in single core.js file using UseRef
// -------------------------------------------------------------------------------
const prodUseRefTasks = function () {
return src(`${buildPath}/*.html`).pipe(useref()).pipe(dest(buildPath));
};
const prodAllTask = series(prodCopyTask, prodRenameTasks, prodUseRefTasks);
// Exports
// ---------------------------------------------------------------------------
return {
copy: prodCopyTask,
rename: prodRenameTasks,
useref: prodUseRefTasks,
all: prodAllTask
};
};