Skip to content

Commit 0c57317

Browse files
committed
wip more work on mobile. index isn't quite right just yet
1 parent 66dfea6 commit 0c57317

33 files changed

+102
-38
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
System.import('system-config.js').then(function () {
2+
System.import('main');
3+
}).catch(console.error.bind(console));

addon/ng2/blueprints/ng2/files/__path__/app/__name__.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Component } from '@angular/core';
88
{{title}}
99
</h1>
1010
`, <% } else { %> templateUrl: '<%= htmlComponentName %>.component.html', <% } %>
11-
<% if(isMobile) { %>styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>'] <% } else { %> styles: [] <% } %>
11+
<% if(!isMobile) { %>styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>'] <% } else { %> styles: [] <% } %>
1212
})
1313
export class <%= jsComponentName %>AppComponent {
1414
title = '<%= htmlComponentName %> works!';

addon/ng2/blueprints/ng2/files/__path__/index.html

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,54 @@
88
{{#unless environment.production}}
99
<script src="/angular-cli-live-reload.js" type="text/javascript"></script>
1010
{{/unless}}
11+
<meta name="viewport" content="width=device-width, initial-scale=1">
1112
<link rel="icon" type="image/x-icon" href="favicon.ico"><% if (isMobile) { %>
12-
<link rel="manifest" href="/manifest.webapp">
13-
<link rel="apple-touch-icon" href="apple-touch-icon.png">
14-
<link rel="apple-touch-icon" sizes="57x57" href="apple-touch-icon-57x57.png">
15-
<link rel="apple-touch-icon" sizes="60x60" href="apple-touch-icon-60x60.png">
16-
<link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72.png">
17-
<link rel="apple-touch-icon" sizes="76x76" href="apple-touch-icon-76x76.png">
18-
<link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x114.png">
19-
<link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x120.png">
20-
<link rel="apple-touch-icon" sizes="144x144" href="apple-touch-icon-144x144.png">
21-
<link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png">
22-
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180.png">
23-
<link rel="apple-touch-startup-image" href="/apple-touch-icon-180x180.png">
2413
<meta name="apple-mobile-web-app-capable" content="yes">
2514
<meta name="theme-color" content="#000000">
26-
<% } %>
27-
<meta name="viewport" content="width=device-width, initial-scale=1">
28-
15+
<link rel="manifest" href="/manifest.webapp">
16+
{{#each mobile.icons}}
17+
<link rel="{{icon.rel}}" {{#if icon.sizes}}sizes="{{icon.sizes}}" {{/if}}href="{{icon.href}}">
18+
{{/each}}
2919

30-
<!-- Service worker support is disabled by default.
31-
Install the worker script and uncomment to enable.
32-
Only enable service workers in production.
20+
{{#if environment.production}}
3321
<script type="text/javascript">
3422
if ('serviceWorker' in navigator) {
3523
navigator.serviceWorker.register('/worker.js').catch(function(err) {
3624
console.log('Error installing service worker: ', err);
3725
});
3826
}
3927
</script>
40-
-->
28+
{{/if}}
29+
<% } %>
4130
</head>
4231
<body>
4332
<<%= htmlComponentName %>-app>Loading...</<%= htmlComponentName %>-app>
4433

45-
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
34+
<% if (isMobile) { %>
35+
36+
{{#if environment.production}}
37+
<script src="/app-concat.js" async></script>
38+
{{else}}
39+
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
40+
<script>
41+
System.import('system-config.js').then(function () {
42+
System.import('main');
43+
}).catch(console.error.bind(console));
44+
</script>
45+
{{/if}}
46+
47+
<% } else { %>
48+
49+
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
50+
<script>
51+
System.import('system-config.js').then(function () {
52+
System.import('main');
53+
}).catch(console.error.bind(console));
54+
</script>
55+
56+
<% } %>
57+
58+
4659

47-
<script>
48-
System.import('system-config.js').then(function () {
49-
System.import('main');
50-
}).catch(console.error.bind(console));
51-
</script>
5260
</body>
5361
</html>

addon/ng2/blueprints/ng2/files/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
"@angular/http": "2.0.0-rc.1",
3131
"@angular/platform-server": "2.0.0-rc.1",
3232
"@angular/router-deprecated": "2.0.0-rc.1",
33-
"angular2-service-worker": "",
33+
"angular2-service-worker": "0.1.11",
3434
"angular2-broccoli-prerender": "^0.11.0",
3535
"angular2-universal":"^0.100.3",
3636
"angular2-universal-polyfills": "^0.4.1",
37+
"broccoli-concat": "^2.2.0",
3738
"preboot": "^2.0.10",<% } %>
3839
"angular-cli": "^<%= version %>",
3940
"clang-format": "^1.0.35",

lib/broccoli/angular2-app.js

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class Angular2App extends BroccoliPlugin {
3030
this._sourceDir = options.sourceDir
3131
|| (this.ngConfig.defaults && this.ngConfig.defaults.sourceDir)
3232
|| 'src';
33+
this._options.polyfills = this._options.polyfills || [
34+
'vendor/es6-shim/es6-shim.js',
35+
'vendor/reflect-metadata/Reflect.js',
36+
'vendor/systemjs/dist/system.src.js',
37+
'vendor/zone.js/dist/zone.js'
38+
];
39+
3340
this._destDir = options.destDir || '';
3441

3542
// By default, add all spec files to the tsCompiler.
@@ -81,6 +88,10 @@ class Angular2App extends BroccoliPlugin {
8188
inputTreeArray.push(new BroccoliFunnel('public', { destDir: 'public' }));
8289
}
8390

91+
if (this.ngConfig.apps[0].mobile && fs.existsSync('icons')) {
92+
inputTreeArray.push(new BroccoliFunnel('icons', { destDir: 'icons' }));
93+
}
94+
8495
return new BroccoliMergeTrees(inputTreeArray, { overwrite: true });
8596
}
8697

@@ -143,11 +154,27 @@ class Angular2App extends BroccoliPlugin {
143154
}
144155

145156
if (loadEnvironment(this.project).production) {
146-
merged = this._getBundleTree(merged);
157+
if (this.ngConfig.apps[0].mobile) {
158+
var concat = require('broccoli-concat');
159+
merged = concat(merged, {
160+
headerFiles: [].concat(this._options.polyfills).concat(this.getVendorScripts()).filter(v => !!v),
161+
inputFiles: [
162+
'system-import.js'
163+
],
164+
header: ';(function() {',
165+
footer: '}());',
166+
sourceMapConfig: { enabled: true },
167+
allowNone: false,
168+
outputFile: '/app-concat.js'
169+
});
170+
} else {
171+
merged = this._getBundleTree(merged);
172+
}
147173
}
148174

149175
return new BroccoliFunnel(merged, {
150-
destDir: this._destDir
176+
destDir: this._destDir,
177+
overwrite: true
151178
});
152179
}
153180

@@ -246,6 +273,7 @@ class Angular2App extends BroccoliPlugin {
246273
var files = [
247274
'index.html'
248275
];
276+
var mobile;
249277

250278
let indexTree = new BroccoliFunnel(this._inputNode, {
251279
include: files.map(name => path.join(this._sourceDir, name)),
@@ -257,17 +285,31 @@ class Angular2App extends BroccoliPlugin {
257285
}
258286
});
259287

288+
if (this.ngConfig.apps[0].mobile) {
289+
mobile = {
290+
icons: [
291+
{ rel: 'apple-touch-icon', href: '/icons/apple-touch-icon.png' },
292+
{ rel: 'apple-touch-icon', sizes: '57x57', href: '/icons/apple-touch-icon-57x57.png'},
293+
{ rel: 'apple-touch-icon', sizes: '60x60', href: '/icons/apple-touch-icon-60x60.png'},
294+
{ rel: 'apple-touch-icon', sizes: '72x72', href: '/icons/apple-touch-icon-72x72.png'},
295+
{ rel: 'apple-touch-icon', sizes: '76x76', href: '/icons/apple-touch-icon-76x76.png'},
296+
{ rel: 'apple-touch-icon', sizes: '114x114', href: '/icons/apple-touch-icon-114x114.png'},
297+
{ rel: 'apple-touch-icon', sizes: '120x120', href: '/icons/apple-touch-icon-120x120.png'},
298+
{ rel: 'apple-touch-icon', sizes: '144x144', href: '/icons/apple-touch-icon-144x144.png'},
299+
{ rel: 'apple-touch-icon', sizes: '152x152', href: '/icons/apple-touch-icon-152x152.png'},
300+
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/icons/apple-touch-icon-180x180.png'},
301+
{ rel: 'apple-touch-startup-image', href: '/icons/apple-touch-icon-180x180.png' }
302+
]
303+
}
304+
}
305+
260306
return new HandlebarReplace(indexTree, {
261307
config: this.ngConfig,
262308
environment: loadEnvironment(this.project),
263309
scripts: {
264-
polyfills: this._options.polyfills || [
265-
'vendor/es6-shim/es6-shim.js',
266-
'vendor/reflect-metadata/Reflect.js',
267-
'vendor/systemjs/dist/system.src.js',
268-
'vendor/zone.js/dist/zone.js'
269-
]
270-
}
310+
polyfills: this._options.polyfills
311+
},
312+
mobile: mobile
271313
}, {
272314
helpers: {
273315
'content-for': (name) => {
@@ -370,10 +412,14 @@ class Angular2App extends BroccoliPlugin {
370412
});
371413
}
372414

373-
_getBundleTree(preBundleTree){
415+
_getVendorScripts() {
374416
var indexFile = path.join(this._sourceDir, 'index.html');
375417
var indexContent = fs.readFileSync(indexFile, 'utf8');
376-
var scriptTagVendorFiles = indexContent.match(/vendor\/[^"']*\.js/gi);
418+
return indexContent.match(/vendor\/[^"']*\.js/gi);
419+
}
420+
421+
_getBundleTree(preBundleTree){
422+
var scriptTagVendorFiles = this._getVendorScripts();
377423

378424
var scriptTree = new BroccoliFunnel(preBundleTree, {
379425
include: scriptTagVendorFiles

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
},
3131
"homepage": "https://github.com/angular/angular-cli",
3232
"dependencies": {
33+
"@angular/common": "^2.0.0-rc.1",
34+
"@angular/compiler": "^2.0.0-rc.1",
35+
"@angular/core": "^2.0.0-rc.1",
36+
"@angular/platform-browser": "^2.0.0-rc.1",
3337
"broccoli": "^1.0.0-beta.7",
3438
"broccoli-caching-writer": "^2.2.1",
3539
"broccoli-concat": "^2.2.0",
@@ -40,6 +44,7 @@
4044
"chalk": "^1.1.3",
4145
"ember-cli": "2.5.0",
4246
"ember-cli-string-utils": "^1.0.0",
47+
"es6-shim": "^0.35.0",
4348
"exit": "^0.1.2",
4449
"fs-extra": "^0.30.0",
4550
"glob": "^7.0.3",
@@ -48,6 +53,7 @@
4853
"lodash": "^4.11.1",
4954
"opn": "4.0.1",
5055
"resolve": "^1.1.7",
56+
"rxjs": "^5.0.0-beta.6",
5157
"shelljs": "^0.7.0",
5258
"silent-error": "^1.0.0",
5359
"symlink-or-copy": "^1.0.3",

0 commit comments

Comments
 (0)