Skip to content

Commit 73758e1

Browse files
authored
Feature: Use @ngtools for build & scss (#279)
* wip * aot/jit client and jit universal working * wip * add server only commands * set to work in all modes * cleanup * improve sass config * update yarn and bump version
1 parent 8c40ff9 commit 73758e1

26 files changed

+175
-190
lines changed

constants.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export declare const MY_VENDOR_DLLS: any[];
2222
export declare const MY_CLIENT_PLUGINS: any[];
2323
export declare const MY_CLIENT_PRODUCTION_PLUGINS: any[];
2424
export declare const MY_CLIENT_RULES: any[];
25-
export declare const MY_SERVER_RULES: any[];
2625
export declare const MY_TEST_PLUGINS: any[];
2726
export declare const MY_TEST_RULES: any[];
28-
export declare const MY_SERVER_INCLUDE_CLIENT_PACKAGES: any[];
2927

3028
export declare const EXCLUDE_SOURCE_MAPS: any[];

constants.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,10 @@ exports.MY_CLIENT_RULES = [
8282
// use this to import your own rules for Client webpack config.
8383
]
8484

85-
exports.MY_SERVER_RULES = [
86-
// use this to import your own rules for Universal Server webpack config.
87-
]
88-
8985
exports.MY_TEST_RULES = [
9086
// use this to import your own rules for Test webpack config.
9187
]
9288

9389
exports.MY_TEST_PLUGINS = [
9490
// use this to import your own Test webpack config plugins.
9591
]
96-
97-
exports.MY_SERVER_INCLUDE_CLIENT_PACKAGES = [
98-
// include these client packages so we can transform their source with webpack loaders
99-
]

package.json

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-webpack2-starter",
3-
"version": "2.1.0",
3+
"version": "3.0.0",
44
"description": "Angular and Webpack 2 Starter",
55
"author": "Qdouble <[email protected]>",
66
"repository": {
@@ -13,18 +13,18 @@
1313
"webdev": "webpack-dev-server",
1414
"webdev:hmr": "npm run webdev -- --inline --hot",
1515
"webpack": "webpack",
16-
"ngc": "./node_modules/.bin/ngc -p tsconfig.aot.json",
16+
"ngc": "./node_modules/.bin/ngc -p src/tsconfig.server.aot.json",
1717
"webdriver-manager": "webdriver-manager",
1818
"webdriver:update": "npm run webdriver-manager update",
1919
"webdriver:start": "npm run webdriver-manager start",
2020
"protractor": "protractor",
2121
"pree2e:only": "npm run webdriver:update -- --standalone",
2222
"e2e": "npm run sass && npm-run-all -p -r e2e:server e2e:only",
2323
"e2e:testall": "npm run e2e:jit && npm run e2e:aot && npm run e2e:universal && npm run e2e:universal:aot",
24-
"e2e:aot": "npm run compile:e2e && npm run e2e",
24+
"e2e:aot": "npm run build:aot:prod:e2e && npm run e2e",
2525
"e2e:jit": "npm run build:prod:e2e && npm run e2e",
2626
"e2e:universal": "npm run build:universal:prod:e2e && npm-run-all -p -r server:universal e2e:only:universal",
27-
"e2e:universal:aot": "npm run compile:universal:e2e && npm-run-all -p -r server:universal e2e:only:universal",
27+
"e2e:universal:aot": "npm run build:universal:aot:e2e && npm-run-all -p -r server:universal e2e:only:universal",
2828
"e2e:only:universal": "npm run protractor -- --universal",
2929
"e2e:only": "npm run protractor",
3030
"e2e:live": "npm run e2e -- --elementExplorer",
@@ -43,21 +43,13 @@
4343
"clean:dist": "npm run rimraf -- dist .awcache",
4444
"clean:dll": "npm run rimraf -- dll",
4545
"clean:compile": "npm run rimraf -- \"compiled\" ",
46-
"compile": "npm run compile:aot",
47-
"compile:aot": "npm run sass && npm run clean:compile && npm run ngc && npm run build:aot",
48-
"compile:e2e": "npm run sass && npm run clean:compile && npm run ngc && npm run build:aot:prod:e2e",
49-
"compile:universal": "npm run sass && npm run clean:compile && npm run ngc && npm run build:universal:aot",
50-
"compile:universal:e2e": "npm run sass && npm run clean:compile && npm run ngc && npm run build:universal:aot:prod:e2e",
51-
"compile:dev": "npm run sass && npm run clean:compile && npm run ngc && npm run build:aot:dev",
52-
"compile:only": "npm run clean:compile && npm run sass && npm run ngc",
53-
"compile:watch": "watch-run -i npm run compile:only -p 'src/app/**/*.ts, src/app/**/*.scss' npm run compile:only",
5446
"prodserver": "node prodserver",
55-
"sass": "node-sass src -o src --include-path node_modules --output-style compressed -q",
47+
"sass": "node-sass \"src/app/styles.scss\" \"src/app/styles.css\" \"src/app/main.scss\" \"src/app/main.css\" --include-path node_modules --output-style compressed -q",
5648
"sass:watch": "node-sass -w src -o src --include-path node_modules --output-style compressed -q",
5749
"start": "npm run server:dev",
5850
"start:hmr": "npm run server:hmr",
5951
"serve80": "sudo PORT=80 node prodserver",
60-
"server:dev": "npm-run-all -p -r webdev sass:watch",
52+
"server:dev": "npm run webdev",
6153
"server:hmr": "npm-run-all -p -r webdev:hmr sass:watch",
6254
"server:prod": "npm-run-all -p -r watch:prod prodserver",
6355
"server:prod80": "npm-run-all -p -r serve80 watch:prod",
@@ -68,24 +60,30 @@
6860
"build:aot:prod": "npm run clean:dist && npm run sass && webpack",
6961
"build:aot:prod:e2e": "npm run clean:dist && npm run sass && webpack",
7062
"build:aot:dev": "npm run clean:dist && npm run sass && webpack",
71-
"build:dev": "npm run clean:dist && npm run sass && webpack",
63+
"build:dev": "npm run clean:dist && webpack",
7264
"build:dll": "npm run clean:dll && npm run sass && webpack",
7365
"build:prod": "npm run clean:dist && npm run sass && webpack",
7466
"build:prod:e2e": "npm run clean:dist && npm run sass && webpack",
67+
"build:server": "npm run build:server:prod",
68+
"build:server:aot": "npm run build:server:aot:prod",
69+
"build:server:aot:dev": "npm run sass && webpack",
70+
"build:server:aot:prod": "npm run sass && webpack",
71+
"build:server:aot:prod:e2e": "npm run sass && webpack",
72+
"build:server:dev": "npm run clean:dist && npm run sass && webpack",
73+
"build:server:prod": "npm run clean:dist && npm run sass && webpack",
7574
"build:universal": "npm run build:universal:prod",
76-
"build:universal:aot": "npm run build:universal:aot:prod",
77-
"build:universal:aot:dev": "npm run clean:dist && npm run sass && webpack",
78-
"build:universal:aot:prod": "npm run clean:dist && npm run sass && webpack",
79-
"build:universal:aot:prod:e2e": "npm run clean:dist && npm run sass && webpack",
75+
"build:universal:aot": "npm-run-all -p build:aot build:server:aot",
76+
"build:universal:aot:dev": "npm-run-all -p build:aot:dev build:server:aot:dev",
77+
"build:universal:aot:e2e": "npm-run-all -p build:aot:prod:e2e build:server:aot:prod:e2e",
8078
"build:universal:dev": "npm run clean:dist && npm run sass && webpack",
8179
"build:universal:prod": "npm run clean:dist && npm run sass && webpack",
8280
"build:universal:prod:e2e": "npm run clean:dist && npm run sass && webpack",
8381
"watch": "npm run watch:dev",
82+
"watch:aot": "npm-run-all -p -r \"build:aot:dev -- --watch\" sass:watch",
8483
"watch:dev": "npm-run-all -p -r \"build:dev -- --watch\" sass:watch",
85-
"watch:prod": "npm-run-all -p -r \"build:prod -- --watch\" sass:watch",
8684
"watch:universal": "npm-run-all -p -r \"build:universal -- --watch\" sass:watch",
8785
"universal": "npm run build:universal && npm run server:universal",
88-
"universal:aot": "npm run compile:universal && npm run server:universal",
86+
"universal:aot": "npm run build:universal:aot && npm run server:universal",
8987
"universal:watch": "npm run build:universal && npm-run-all -p -r watch:universal server:universal"
9088
},
9189
"dependencies": {
@@ -171,6 +169,7 @@
171169
"protractor": "~4.0.8",
172170
"raw-loader": "~0.5.1",
173171
"rimraf": "~2.6.1",
172+
"sass-loader": "^6.0.5",
174173
"source-map-loader": "~0.2.1",
175174
"string-replace-loader": "~1.2.0",
176175
"to-string-loader": "~1.1.5",

src/app/app-nav-views.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ export const views: Object[] = [
88
name: 'Lazy',
99
icon: 'file_download',
1010
link: ['lazy']
11-
},
12-
{
13-
name: 'Sync',
14-
icon: 'done',
15-
link: ['sync']
1611
},
1712
{
1813
name: 'Bad Link',

src/app/app.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
22
import { ActivatedRoute, Router } from '@angular/router';
33
import { TransferState } from '../modules/transfer-state/transfer-state';
44

@@ -7,8 +7,9 @@ import { MOBILE } from './services/constants';
77

88
@Component({
99
selector: 'my-app',
10-
styleUrls: ['./app.component.css'],
11-
templateUrl: './app.component.html'
10+
styleUrls: ['main.scss', './app.component.scss'],
11+
templateUrl: './app.component.html',
12+
encapsulation: ViewEncapsulation.None
1213
})
1314
export class AppComponent implements OnInit {
1415
showMonitor = (ENV === 'development' && !AOT &&

src/app/app.imports.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useLogMonitor } from '@ngrx/store-log-monitor';
1010

1111
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
1212

13-
import { routes } from './app.routing';
1413
import { rootReducer } from './reducers';
1514
import { StoreDevToolsModule } from './features/store-devtools.module';
1615
import { UserEffects } from './user/user.effects';
@@ -31,7 +30,6 @@ export const APP_IMPORTS = [
3130
EffectsModule.run(UserEffects),
3231
// MaterialModule,
3332
ReactiveFormsModule,
34-
RouterModule.forRoot(routes, { useHash: false, preloadingStrategy: PreloadAllModules }),
3533
RouterStoreModule.connectRouter(),
3634
StoreModule.provideStore(rootReducer),
3735
STORE_DEV_TOOLS_IMPORTS,

src/app/app.module.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*/
88

99
import { ApplicationRef, NgModule } from '@angular/core';
10-
import { BrowserModule } from '@angular/platform-browser';
10+
import { CommonModule } from '@angular/common';
1111
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
1212
import { HttpModule } from '@angular/http';
13+
import { RouterModule, PreloadAllModules } from '@angular/router';
1314

1415
import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularclass/hmr';
1516

@@ -24,7 +25,10 @@ import { APP_ENTRY_COMPONENTS } from './app.entry-components';
2425
import { APP_IMPORTS } from './app.imports';
2526
import { APP_PROVIDERS } from './app.providers';
2627

28+
import { routes } from './app.routing';
29+
2730
import { AppComponent } from './app.component';
31+
import { DashboardComponent } from './features/dashboard.component';
2832

2933
import { AppState } from './reducers';
3034

@@ -35,12 +39,14 @@ import { AppState } from './reducers';
3539
],
3640
entryComponents: [APP_ENTRY_COMPONENTS],
3741
imports: [
38-
APP_IMPORTS,
39-
BrowserModule,
42+
CommonModule,
4043
DEV_SERVER ? [BrowserAnimationsModule, BrowserTransferStateModule] : [],
4144
HttpModule,
45+
APP_IMPORTS,
46+
RouterModule.forRoot(routes, { useHash: false, preloadingStrategy: PreloadAllModules }),
4247
],
4348
bootstrap: [AppComponent],
49+
exports: [AppComponent],
4450
providers: [APP_PROVIDERS]
4551
})
4652

src/app/app.routing.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ import { NotFound404Component } from './not-found404.component';
77
export const routes: Routes = [
88
{ path: '', component: DashboardComponent, pathMatch: 'full' },
99
{ path: 'lazy', loadChildren: './features/lazy/index#LazyModule' },
10-
{ path: 'sync', loadChildren: './features/sync/index#SyncModule?sync=true' },
1110
{ path: '**', component: NotFound404Component }
1211
];

src/app/features/sync/index.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/app/features/sync/sync.component.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/app/features/sync/sync.component.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/app/features/sync/sync.routing.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/main.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/* main.css will be extracted to main dist folder and is imported in index.html */
21
/* This file is for setting global styles */
32
@import 'variables';

src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
1111
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css" />
1212
<link rel="stylesheet" href="styles.css" />
13-
<link rel="stylesheet" href="main.css" />
1413
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
1514
<style>#str-dlls { display: none }</style>
1615
</head>

src/main.browser.aot.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/polyfills.browser.aot.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/server.aot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import './rxjs.imports';
66
import * as express from 'express';
77
import * as path from 'path';
88
import { platformServer, renderModuleFactory } from '@angular/platform-server';
9-
import { ServerAppModuleNgFactory } from '../compiled/src/app/server.app.module.ngfactory';
9+
import { ServerAppModuleNgFactory } from './ngfactory/app/server.app.module.ngfactory';
1010
import { ngExpressEngine } from '@nguniversal/express-engine';
1111
import { routes } from './server.routes';
1212
import { App } from './mock-api/app';

src/tsconfig.browser.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../tsconfig.webpack.json",
3+
"angularCompilerOptions": {
4+
"entryModule": "./app/browser.app.module#BrowserAppModule"
5+
},
6+
"exclude": [
7+
"./server.aot.ts"
8+
]
9+
}

src/tsconfig.server.aot.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.server.json",
3+
"angularCompilerOptions": {
4+
"genDir": "ngfactory",
5+
"entryModule": "./app/server.app.module#ServerAppModule"
6+
},
7+
"exclude": []
8+
}

src/tsconfig.server.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../tsconfig.webpack.json",
3+
"angularCompilerOptions": {
4+
"entryModule": "./app/server.app.module#ServerAppModule"
5+
},
6+
"exclude": [
7+
"./server.aot.ts"
8+
]
9+
}

tsconfig.aot.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)