-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
83 lines (58 loc) · 1.69 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
const gulp = require('gulp')
const directoryName = 'public';
const fs = require('fs')
let isDev = process.argv.indexOf('--dev') >= 0;
let isProd = !isDev;
require('marko/node-require');
require('lasso').configure({
"plugins": [{
"plugin": "lasso-marko"
},
{
"plugin": "lasso-less"
}
],
"fileWriter": {
"outputDir": `${directoryName}/static`,
"fingerprintsEnabled": isProd,
"urlPrefix": "static/"
},
"minify": isProd,
"resolveCssUrls": true,
"bundlingEnabled": false,
"bundles": [
]
});
gulp.task('mkdir', function () {
var outputDirectory = path.dirname(`./${directoryName}`)
if (!fs.existsSync(outputDirectory)) {
fs.mkdirSync(outputDirectory)
}
})
gulp.task('copy', function () {
return gulp.src(['./images/**/*'])
.pipe(gulp.dest(`./${directoryName}/images`))
});
gulp.task('marko', ['copy'], function (cb) {
return renderPage('app-root','index.html');
// return Promise.all([
// renderPage('app-root'),
// renderPage('schedule'),
// renderPage('proposal-list'),
// renderPage('proposal'),
// renderPage('profile'),
// renderPage('speakers')
// ]);
})
function renderPage(pageName,htmlFileName) {
return new Promise(function (resolve, reject) {
let main = require(`./src/components/${pageName}/${pageName}`);
var htmlProm = main.render({});
htmlProm.then((html) => {
fs.writeFileSync(`./${directoryName}/` + htmlFileName, html)
console.log('done rendering: ', `${htmlFileName}`)
resolve();
})
})
}
gulp.task('default', ['marko']);