-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-app.js
33 lines (29 loc) · 1.09 KB
/
build-app.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
var fs = require('fs');
var ncp = require('ncp').ncp;
var mkdirp = require('mkdirp');
const source = './build/static';
const destination = './app/www/';
['css', 'js'].forEach(type => {
const basePath = `./build/static/${type}`;
fs.readdir(basePath, 'utf-8', (err, files) => {
files.filter(file => file !== null && file.endsWith(`.${type}`)).forEach(file => {
var filePath = `${basePath}/${file}`;
fs.readFile(filePath, 'utf-8', (err, data) => {
var destinationBasePath = `${destination}${type}`
mkdirp(destinationBasePath, err => {
if (err) {
console.log(err);
return;
}
fs.writeFile(`${destinationBasePath}/index.${type}`, data, 'utf-8', (err) => {
if (err) {
console.log(err);
return;
}
console.log("Copied: " + filePath);
});
});
});
});
});
});