Skip to content

Commit 8c90be7

Browse files
committed
Production build
1 parent 7fdd04a commit 8c90be7

9 files changed

+111
-2015
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ node_modules
22
bower_components
33
dist
44
temp
5+
vendor
56
.DS_Store
67
*.log

Gruntfile.js

+91-20
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,48 @@ module.exports = function (grunt) {
33

44
grunt.initConfig({
55

6+
pkg: grunt.file.readJSON('package.json'),
7+
68
path: {
79
// Source folders
810
app: 'app',
9-
app_js: 'app/app-js',
10-
less: 'app/less',
11+
app_appjs: 'app/app-js',
12+
app_style: 'app/less',
13+
app_vendor: 'app/vendor',
1114

1215
// Intermediate folders (transient)
1316
temp: 'temp',
17+
bower: 'bower_components',
1418

1519
// Output folders (transient)
1620
dist: 'dist',
21+
dist_appjs: 'dist/app-js',
1722
dist_style: 'dist/style',
1823
dist_vendor: 'dist/vendor'
1924
},
2025

2126
clean: {
22-
dist: ['<%- path.dist %>', '<%- path.temp %>']
27+
all: [
28+
'<%- path.app_vendor %>',
29+
'<%- path.dist %>',
30+
'<%- path.temp %>',
31+
'<%- path.bower %>'
32+
]
2333
},
2434

2535
less: {
2636
options: {
2737
paths: [
28-
'<%- path.dist_vendor %>',
38+
'<%- path.app_vendor %>',
2939
'<%- path.temp %>'
30-
]
40+
],
41+
cleancss: false
3142
},
3243

3344
precompile: {
3445
files: {
3546
'<%- path.temp %>/engine-ui-grid-precompile.less':
36-
'<%- path.less %>/engine-ui-grid.less'
47+
'<%- path.app_style %>/engine-ui-grid.less'
3748
}
3849
},
3950

@@ -45,16 +56,15 @@ module.exports = function (grunt) {
4556
},
4657
files: {
4758
'<%- path.dist_style %>/hosted-apis.css':
48-
'<%- path.less %>/hosted-apis.less'
59+
'<%- path.app_style %>/hosted-apis.less'
4960
}
5061
}
5162
},
5263

5364
bower: {
5465
install: {
5566
options: {
56-
targetDir: '<%- path.dist_vendor %>',
57-
verbose: true,
67+
targetDir: '<%- path.app_vendor %>',
5868
layout: 'byComponent',
5969
bowerOptions: {
6070
production: true
@@ -63,20 +73,47 @@ module.exports = function (grunt) {
6373
}
6474
},
6575

76+
copy: {
77+
prod: {
78+
expand: true,
79+
cwd: '<%- path.app %>',
80+
src: [
81+
'img/**/*',
82+
'**/font/**/*'
83+
],
84+
dest: '<%- path.dist %>'
85+
},
86+
87+
prod_versioned: {
88+
expand: true,
89+
cwd: '<%- path.app %>',
90+
src: ['index.html'],
91+
dest: '<%- path.dist %>',
92+
options: {
93+
process: function (content) {
94+
return content
95+
.replace(/\{version\}/g, grunt.config.data.pkg.version)
96+
.replace('src="vendor/requirejs/require.js" data-main="app-js/app-require.js"',
97+
'src="app.js?v=' + grunt.config.data.pkg.version + '"');
98+
}
99+
}
100+
}
101+
},
102+
66103
shell: {
67104
options: {
68105
stdout: true,
69106
stderr: true,
70107
failOnError: true
71108
},
72109

73-
sync_app: {
110+
sync_dev: {
74111
command: [
75112
'cwd=$(pwd)',
76113
'cd <%- path.app %>',
77114
'rsync . $cwd/<%- path.dist %> ' +
78115
'--update --delete --verbose --recursive ' +
79-
'--exclude less --exclude style --exclude vendor'
116+
'--exclude ./less --exclude ./style'
80117
].join('&&')
81118
},
82119

@@ -90,20 +127,40 @@ module.exports = function (grunt) {
90127
}
91128
},
92129

130+
requirejs: {
131+
prod: {
132+
options: {
133+
baseUrl: '<%- path.app_appjs %>',
134+
out: '<%- path.dist %>/app.js',
135+
mainConfigFile: '<%- path.app_appjs %>/app-require.js',
136+
name: '../vendor/almond/almond',
137+
include: ['app-start'],
138+
stubModules: ['text', 'hgn'],
139+
optimize: 'uglify2',
140+
preserveLicenseComments: false,
141+
insertRequire: ['app-start'],
142+
paths: {
143+
'lib/logger': 'lib/logger-prod',
144+
'lib/eventDebugger': 'lib/eventDebugger-prod'
145+
}
146+
}
147+
}
148+
},
149+
93150
jshint: {
94151
options: {
95152
jshintrc: true
96153
},
97154

98-
app: ['Gruntfile.js', '<%- path.app_js %>/**/*.js']
155+
app: ['Gruntfile.js', '<%- path.app_appjs %>/**/*.js']
99156
},
100157

101158
jscs: {
102159
options: {
103-
config: '<%- path.app_js %>/.jscsrc'
160+
config: '<%- path.app_appjs %>/.jscsrc'
104161
},
105162

106-
app: ['Gruntfile.js', '<%- path.app_js %>/**/*.js']
163+
app: ['Gruntfile.js', '<%- path.app_appjs %>/**/*.js']
107164
},
108165

109166
watch: {
@@ -114,14 +171,14 @@ module.exports = function (grunt) {
114171
app: {
115172
files: [
116173
'<%- path.app %>/**/*',
117-
'!<%- path.less %>/**/*'
174+
'!<%- path.app_style %>/**/*'
118175
],
119-
tasks: ['shell:sync_app']
176+
tasks: ['shell:sync_dev']
120177
},
121178

122179
less: {
123180
files: [
124-
'<%- path.less %>/**/*',
181+
'<%- path.app_style %>/**/*',
125182
'<%- path.dist_vendor %>/engine-ui/less/**/*'
126183
],
127184
tasks: ['less:app']
@@ -146,12 +203,26 @@ module.exports = function (grunt) {
146203
// bring in all grunt plugins from package.json
147204
require('load-grunt-tasks')(grunt);
148205

149-
grunt.registerTask('dist-dev', [
150-
'shell:sync_app',
206+
grunt.registerTask('set-prod', function () {
207+
grunt.config.data.less.options.cleancss = true;
208+
grunt.config.data.less.app.options.sourceMap = false;
209+
});
210+
211+
grunt.registerTask('build-dev', [
151212
'bower',
213+
'shell:sync_dev',
152214
'less',
153215
'shell:sourcemap_links'
154216
]);
155217

156-
grunt.registerTask('default', ['dist-dev']);
218+
grunt.registerTask('build-prod', [
219+
'set-prod',
220+
'clean',
221+
'bower',
222+
'copy',
223+
'less',
224+
'requirejs'
225+
]);
226+
227+
grunt.registerTask('default', ['build-dev']);
157228
};

app/img/placeholder

-1
This file was deleted.

app/index.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Engine Hosted APIs</title>
6-
<link href="style/hosted-apis.css" rel="stylesheet" />
6+
<link href="style/hosted-apis.css?v={version}" rel="stylesheet" />
77
</head>
88
<body>
99

@@ -14,8 +14,6 @@
1414
</div>
1515
<div id="loading-region"></div>
1616

17-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
1817
<script src="vendor/requirejs/require.js" data-main="app-js/app-require.js" type="text/javascript"></script>
19-
<!-- <script src="lib/js-input-expand" type="text/javascript"></script> -->
2018
</body>
2119
</html>

0 commit comments

Comments
 (0)