Skip to content

Commit

Permalink
Clone common-styles app to theming app
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafnur committed Aug 11, 2019
1 parent 82b08b8 commit de114c5
Show file tree
Hide file tree
Showing 47 changed files with 828 additions and 1 deletion.
117 changes: 117 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,123 @@
}
}
},
"frontend-theming": {
"projectType": "application",
"schematics": {
"@nrwl/angular:component": {
"style": "scss",
"changeDetection": "OnPush"
}
},
"root": "apps/frontend/theming",
"sourceRoot": "apps/frontend/theming/src",
"prefix": "medium-stories",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apps/frontend/theming/browser",
"index": "apps/frontend/theming/src/index.html",
"main": "apps/frontend/theming/src/main.browser.ts",
"polyfills": "apps/frontend/theming/src/polyfills.ts",
"tsConfig": "apps/frontend/theming/tsconfig.app.json",
"aot": false,
"assets": ["apps/frontend/theming/src/favicon.ico", "apps/frontend/theming/src/assets"],
"styles": ["apps/frontend/theming/src/styles.scss"],
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/theming/src/styles"]
},
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/frontend/theming/src/environments/environment.ts",
"with": "apps/frontend/theming/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-theming:build"
},
"configurations": {
"production": {
"browserTarget": "frontend-theming:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend-theming:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/frontend/theming/tsconfig.app.json", "apps/frontend/theming/tsconfig.spec.json"],
"exclude": ["**/node_modules/**", "!apps/frontend/theming/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/frontend/theming/jest.config.js",
"tsConfig": "apps/frontend/theming/tsconfig.spec.json",
"setupFile": "apps/frontend/theming/src/test-setup.ts"
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"bundleDependencies": "none",
"outputPath": "dist/apps/frontend/theming/server",
"main": "apps/frontend/theming/src/main.server.ts",
"tsConfig": "apps/frontend/theming/tsconfig.server.json",
"stylePreprocessorOptions": {
"includePaths": ["apps/frontend/theming/src/styles"]
}
},
"configurations": {
"production": {
"bundleDependencies": "all",
"fileReplacements": [
{
"replace": "apps/frontend/theming/src/environments/environment.ts",
"with": "apps/frontend/theming/src/environments/environment.prod.ts"
}
],
"sourceMap": false,
"optimization": {
"scripts": false,
"styles": true
}
}
}
}
}
},
"frontend-translation": {
"projectType": "application",
"schematics": {
Expand Down
12 changes: 12 additions & 0 deletions apps/frontend/theming/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/theming/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/theming/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/theming';
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/theming/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/theming/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/theming/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/theming/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/theming/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/theming/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();
});
});
27 changes: 27 additions & 0 deletions apps/frontend/theming/src/app/app.server.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { NgModule } from '@angular/core';
import { ServerModule, ServerTransferStateModule } from '@angular/platform-server';
import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';

import { ServerStorageModule } from '@medium-stories/storage';
import { ServerTranslationModule } from '@medium-stories/translation';

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

@NgModule({
imports: [
AppModule,
CoreModule,
ServerStorageModule.forRoot(),
ServerModule,
ServerTranslationModule.forRoot({
config: environment.translation
}),
ModuleMapLoaderModule,
ServerTransferStateModule
],
bootstrap: [AppComponent]
})
export class AppServerModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<router-outlet></router-outlet>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { AppComponent } from './app.component';

describe('AppComponent', () => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;

beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
14 changes: 14 additions & 0 deletions apps/frontend/theming/src/app/core/containers/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component } from '@angular/core';

import { TranslationFacade } from '@medium-stories/translation';

@Component({
selector: 'medium-stories-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private translationFacade: TranslationFacade) {
this.translationFacade.init();
}
}
Loading

0 comments on commit de114c5

Please sign in to comment.