Project

General

Profile

Download (2.13 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / flarecast / workspace / client-admin / build-js.md @ master

1
# Compress sources
2

    
3
## Compress admin source
4

    
5
### Pre requisite
6

    
7
Install nodejs on Ubuntu
8
	
9
	//Configuration du proxy (if needed)
10
	export http_proxy=http://user:password@proxy2.akka.eu:9090
11
	export https_proxy=http://user:password@proxy2.akka.eu:9090
12
	//add custom repository to have last nodejs version
13
	sudo -E apt-add-repository ppa:chris-lea/node.js
14
	//install nodejs
15
	sudo apt-get update
16
	sudo apt-get install nodejs
17
	//Configure nodejs repository in http to avoid proxy problems
18
	npm config set registry http://registry.npmjs.org/
19

    
20

    
21

    
22
Configure the proxy (if needed)
23

    
24
	npm config set proxy http://proxy.company.com:8080
25
	npm config set https-proxy http://proxy.company.com:8080
26

    
27
### Intialise gulp
28

    
29
	npm install gulp gulp-concat gulp-uglifyjs
30

    
31

    
32
### Build sources
33

    
34
	gulp
35

    
36
### Update the freemarker template (index.html equivalent)
37

    
38
Go to the *data/freemarker* folder.
39

    
40
Edit the adminIndex.ftl file.
41

    
42
Comment all script tags between
43

    
44
	<!-- BEGIN_JS_DEV_INCLUDES --> and  <!-- END_JS_DEV_INCLUDES -->
45
	
46
and uncomment all script tags between
47

    
48
	<!-- BEGIN_PROD and END PROD -->
49
	
50
### Refresh the file list JSON file
51

    
52
The build process is based on a single json file that contains the **ordered** list of all files to build.
53
In order to create or refresh that list, you can follow the following steps :
54

    
55
1.  Run SITools2 admin with Google chrome
56
2.  Open the javascript console by pressing f12
57
3.  In the javascript console run :
58
	
59
		var out = [];
60
		//loop through all classes loaded to get the file path
61
		Ext.each(Ext.Loader.history, function(classz) {
62
			var filePath = Ext.Loader.classNameToFilePathMap[classz];
63
			if(!Ext.isEmpty(filePath)) {
64
				// update the filePath to quope with url rewriting
65
				filePath = filePath.replace("client-public/", "client-public-3.0/");
66
				filePath = filePath.replace("./js/", "js/");
67
				out.push(filePath);
68
			}
69
		});
70
		// Stringigy the output array
71
		var out = JSON.stringify(out);
72
		// add a breakline add the end of each line to make it easier to read
73
		var reEndOfLine = new RegExp('",', 'g');
74
		out = out.replace(reEndOfLine, '",\n');
75
		out;
76

    
77
4. Copy and paste the result into the *conf/files.json* file
78
5. Run the gulp task again