|
| 1 | +var request = require('superagent'); |
| 2 | +var fs = require('fs-extra'); |
| 3 | +var http = require('http-get'); |
| 4 | +var rjs = require('requirejs'); |
| 5 | +var knox = require('knox'); |
| 6 | +var glob = require("glob") |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +var version = Date.now(); |
| 11 | +var outputFolder = 'output/version/' + version |
| 12 | +console.log('Building client'); |
| 13 | +var startTime = Date.now(); |
| 14 | + |
| 15 | +fs.removeSync('output'); |
| 16 | +fs.mkdirSync('output'); |
| 17 | +fs.mkdirSync('output/version'); |
| 18 | +fs.mkdirSync(outputFolder); |
| 19 | +var rootPath = '..'; |
| 20 | + rjs.optimize({ |
| 21 | + name: 'almond', |
| 22 | + include: ['main'], |
| 23 | + out: outputFolder + '/js/main.js', |
| 24 | + findNestedDependencies: true, |
| 25 | + mainConfigFile: rootPath + '/js/main.js', |
| 26 | + wrap: true |
| 27 | +}); |
| 28 | +var index = fs.readFileSync(rootPath + '/index.html', 'ascii'); |
| 29 | +index = index.replace('js/libs/require/require.js', 'version/' + version + '/js/main.js'); |
| 30 | +index = index.replace('css/styles.css', 'version/' + version + '/css/styles.css'); |
| 31 | +index = index.replace(' data-main="js/main"', ''); |
| 32 | +fs.writeFileSync('output/index.html', index); |
| 33 | + rjs.optimize({ |
| 34 | + cssIn: rootPath + '/css/styles.css', |
| 35 | + out: outputFolder + '/css/styles.css' |
| 36 | +}); |
| 37 | + fs.copy(rootPath + '/googleaa49fe030680ef6c.html', 'output/googleaa49fe030680ef6c.html', function (){ |
| 38 | + fs.copy(rootPath + '/favicon.ico', 'output/favicon.ico', function (){ |
| 39 | + fs.copy(rootPath + '/img', outputFolder +'/img', function () { |
| 40 | + fs.copy(rootPath + '/css/Aller_Std_Rg.ttf', outputFolder +'/css/Aller_Std_Rg.ttf', function () { |
| 41 | + var endTime = (Date.now() - startTime) / 1000; |
| 42 | + |
| 43 | + }); |
| 44 | + }); |
| 45 | + }); |
| 46 | + }); |
| 47 | + |
0 commit comments