-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clone common-styles app to theming app
- Loading branch information
Showing
47 changed files
with
828 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
1 change: 1 addition & 0 deletions
1
apps/frontend/theming/src/app/core/containers/app/app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<router-outlet></router-outlet> |
Empty file.
26 changes: 26 additions & 0 deletions
26
apps/frontend/theming/src/app/core/containers/app/app.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
apps/frontend/theming/src/app/core/containers/app/app.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.