Skip to content

Commit

Permalink
Merge branch 'feature/common-styles' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafnur committed Aug 10, 2019
2 parents e452e12 + 19f668d commit 7227b85
Show file tree
Hide file tree
Showing 75 changed files with 1,082 additions and 8 deletions.
154 changes: 153 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,123 @@
}
}
},
"frontend-common-styles": {
"projectType": "application",
"schematics": {
"@nrwl/angular:component": {
"style": "scss",
"changeDetection": "OnPush"
}
},
"root": "apps/frontend/common-styles",
"sourceRoot": "apps/frontend/common-styles/src",
"prefix": "medium-stories",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apps/frontend/common-styles/browser",
"index": "apps/frontend/common-styles/src/index.html",
"main": "apps/frontend/common-styles/src/main.browser.ts",
"polyfills": "apps/frontend/common-styles/src/polyfills.ts",
"tsConfig": "apps/frontend/common-styles/tsconfig.app.json",
"aot": false,
"assets": ["apps/frontend/common-styles/src/favicon.ico", "apps/frontend/common-styles/src/assets"],
"styles": ["apps/frontend/common-styles/src/styles.scss"],
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/common-styles/src/styles"]
},
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/frontend/common-styles/src/environments/environment.ts",
"with": "apps/frontend/common-styles/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend-common-styles:build"
},
"configurations": {
"production": {
"browserTarget": "frontend-common-styles:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend-common-styles:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/frontend/common-styles/tsconfig.app.json", "apps/frontend/common-styles/tsconfig.spec.json"],
"exclude": ["**/node_modules/**", "!apps/frontend/common-styles/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/frontend/common-styles/jest.config.js",
"tsConfig": "apps/frontend/common-styles/tsconfig.spec.json",
"setupFile": "apps/frontend/common-styles/src/test-setup.ts"
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"bundleDependencies": "none",
"outputPath": "dist/apps/frontend/common-styles/server",
"main": "apps/frontend/common-styles/src/main.server.ts",
"tsConfig": "apps/frontend/common-styles/tsconfig.server.json",
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/common-styles/src/styles"]
}
},
"configurations": {
"production": {
"bundleDependencies": "all",
"fileReplacements": [
{
"replace": "apps/frontend/common-styles/src/environments/environment.ts",
"with": "apps/frontend/common-styles/src/environments/environment.prod.ts"
}
],
"sourceMap": false,
"optimization": {
"scripts": false,
"styles": true
}
}
}
}
}
},
"frontend-storage": {
"projectType": "application",
"schematics": {
Expand Down Expand Up @@ -496,6 +613,9 @@
"aot": false,
"assets": ["apps/frontend/translation-state/src/favicon.ico", "apps/frontend/translation-state/src/assets"],
"styles": ["apps/frontend/translation-state/src/styles.scss"],
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/translation-state/src/styles"]
},
"scripts": []
},
"configurations": {
Expand Down Expand Up @@ -563,7 +683,10 @@
"bundleDependencies": "none",
"outputPath": "dist/apps/frontend/translation-state/server",
"main": "apps/frontend/translation-state/src/main.server.ts",
"tsConfig": "apps/frontend/translation-state/tsconfig.server.json"
"tsConfig": "apps/frontend/translation-state/tsconfig.server.json",
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/translation-state/src/styles"]
}
},
"configurations": {
"production": {
Expand Down Expand Up @@ -613,6 +736,35 @@
}
}
},
"layouts": {
"projectType": "library",
"root": "libs/layouts",
"sourceRoot": "libs/layouts/src",
"prefix": "medium-stories",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/layouts/tsconfig.lib.json", "libs/layouts/tsconfig.spec.json"],
"exclude": ["**/node_modules/**", "!libs/layouts/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/layouts/jest.config.js",
"tsConfig": "libs/layouts/tsconfig.spec.json",
"setupFile": "libs/layouts/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/angular:component": {
"styleext": "scss",
"changeDetection": "OnPush"
}
}
},
"storage": {
"projectType": "library",
"root": "libs/storage",
Expand Down
12 changes: 12 additions & 0 deletions apps/frontend/common-styles/browserslist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# You can see what browsers were selected by your queries by running:
# npx browserslist

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
6 changes: 6 additions & 0 deletions apps/frontend/common-styles/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
name: 'frontend-base',
preset: '../../../jest.config.js',
coverageDirectory: '../../../coverage/apps/frontend/base',
snapshotSerializers: ['jest-preset-angular/AngularSnapshotSerializer.js', 'jest-preset-angular/HTMLCommentSerializer.js']
};
82 changes: 82 additions & 0 deletions apps/frontend/common-styles/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* *** NOTE ON IMPORTING FROM ANGULAR AND NGUNIVERSAL IN THIS FILE ***
*
* If your application uses third-party dependencies, you'll need to
* either use Webpack or the Angular CLI's `bundleDependencies` feature
* in order to adequately package them for use on the server without a
* node_modules directory.
*
* However, due to the nature of the CLI's `bundleDependencies`, importing
* Angular in this file will create a different instance of Angular than
* the version in the compiled application code. This leads to unavoidable
* conflicts. Therefore, please do not explicitly import from @angular or
* @nguniversal in this file. You can export any needed resources
* from your application's main.server.ts file, as seen below with the
* import for `ngExpressEngine`.
*/
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
import 'zone.js/dist/zone-node';

import * as express from 'express';
import { join } from 'path';

// Express server
const app = express();

const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), 'dist', 'apps');
const appName = 'frontend/common-styles';
const appBrowser = join(DIST_FOLDER, appName, 'browser');

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
AppServerModuleNgFactory,
LAZY_MODULE_MAP,
ngExpressEngine,
provideModuleMap
} = require('../../../dist/apps/frontend/common-styles/server/main');

// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine(
'html',
ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [provideModuleMap(LAZY_MODULE_MAP)]
})
);

app.set('view engine', 'html');
app.set('views', appBrowser);

// Example Express Rest API endpoints
// app.get('/api/**', (req, res) => { });
// Serve static files from /browser
app.get(
'*.*',
express.static(appBrowser, {
maxAge: '1y'
})
);

// All regular routes use the Universal engine
app.get('*', (req, res) => {
res.render(join(appBrowser, 'index.html'), {
req,
res,
providers: [
{
provide: REQUEST,
useValue: req
},
{
provide: RESPONSE,
useValue: res
}
]
});
});

// Start up the Node server
app.listen(PORT, () => {
console.log(`Node Express server listening on http://localhost:${PORT}`);
});
15 changes: 15 additions & 0 deletions apps/frontend/common-styles/src/app/app.browser.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { async, TestBed } from '@angular/core/testing';

import { AppBrowserModule } from './app.browser.module';

describe('AppBrowserModule', () => {
beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [AppBrowserModule]
}).compileComponents();
}));

it('should create', () => {
expect(AppBrowserModule).toBeTruthy();
});
});
26 changes: 26 additions & 0 deletions apps/frontend/common-styles/src/app/app.browser.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';

import { BrowserStorageModule } from '@medium-stories/storage';
import { BrowserTranslationModule } from '@medium-stories/translation';

import { AppModule } from './app.module';
import { CoreModule } from './core/core.module';
import { AppComponent } from './core/containers/app/app.component';
import { environment } from '../environments/environment';

@NgModule({
imports: [
AppModule,
CoreModule,
BrowserAnimationsModule,
BrowserStorageModule.forRoot(),
BrowserTranslationModule.forRoot({
config: environment.translation
}),
!environment.production ? StoreDevtoolsModule.instrument({ logOnly: environment.production }) : []
],
bootstrap: [AppComponent]
})
export class AppBrowserModule {}
15 changes: 15 additions & 0 deletions apps/frontend/common-styles/src/app/app.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { async, TestBed } from '@angular/core/testing';

import { AppModule } from './app.module';

describe('AppModule', () => {
beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [AppModule]
}).compileComponents();
}));

it('should create', () => {
expect(AppModule).toBeTruthy();
});
});
22 changes: 22 additions & 0 deletions apps/frontend/common-styles/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule, BrowserTransferStateModule } from '@angular/platform-browser';
import { TransferHttpCacheModule } from '@nguniversal/common';

import { APP_DIST } from '@medium-stories/common';

@NgModule({
imports: [
BrowserModule.withServerTransition({ appId: 'medium-stories' }),
HttpClientModule,
BrowserTransferStateModule,
TransferHttpCacheModule
],
providers: [
{
provide: APP_DIST, // need to get translation path on Universal
useValue: 'frontend/translation'
}
]
})
export class AppModule {}
15 changes: 15 additions & 0 deletions apps/frontend/common-styles/src/app/app.server.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { async, TestBed } from '@angular/core/testing';

import { AppServerModule } from './app.server.module';

describe('AppServerModule', () => {
beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [AppServerModule]
}).compileComponents();
}));

it('should create', () => {
expect(AppServerModule).toBeTruthy();
});
});
Loading

0 comments on commit 7227b85

Please sign in to comment.