Skip to content

Instantly share code, notes, and snippets.

View anthanh's full-sized avatar
👾
Cooking some magic stuff

Anthanh anthanh

👾
Cooking some magic stuff
View GitHub Profile
@anthanh
anthanh / arduino port setup
Last active August 29, 2015 14:13
Linux arduino port setup
sudo apt-get install gcc-avr avr-libc
sudo adduser [user] vboxusers
sudo usermod -a -G tty [user]
sudo usermod -a -G dialout [user]
logout/login
@anthanh
anthanh / table-emmet
Created February 20, 2015 19:36
Emmet table example
table[name="pepe"]>thead>tr>th*3^^+tbody>tr*7>td{Basico}*3
@anthanh
anthanh / setup.sh
Last active December 10, 2017 23:03
Angular 5 with Universal and TransferState: Setup
ng new angular-universal-example — style=scss
cd angular-universal-example
@anthanh
anthanh / 0-setup.sh
Last active December 10, 2017 23:08
Angular 5 with Universal and TransferState: Example app with material.io
# install material dependency
npm i -S @angular/material @angular/cdk
@anthanh
anthanh / app.server.module.ts
Last active December 10, 2017 23:16
Angular 5 with Universal and TransferState: app server module
// app.server.module.ts
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
@NgModule({
imports: [
AppModule,
@anthanh
anthanh / main.server.ts
Created December 10, 2017 23:18
Angular 5 with Universal and TransferState: Main server file
// main.server.ts
export { AppServerModule } from './app/app.server.module';
@anthanh
anthanh / 0-tsconfig.server.json
Last active December 12, 2017 23:23
Angular 5 with Universal and TransferState: tsconfig.server.json & angular-cli.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "commonjs",
"types": []
},
"exclude": [
"test.ts",
@anthanh
anthanh / server.ts
Created December 10, 2017 23:29
Angular 5 with Universal and TransferState: Express app
// server.ts
import 'reflect-metadata';
import 'zone.js/dist/zone-node';
import { renderModuleFactory } from '@angular/platform-server';
import { enableProdMode } from '@angular/core';
import * as express from 'express';
import { join } from 'path';
import { readFileSync } from 'fs';
enableProdMode();
@anthanh
anthanh / webpack.config.ts
Last active December 12, 2017 23:32
Angular 5 with Universal and TransferState: Webpack config
// webpack.config.ts
const path = require('path');
var nodeExternals = require('webpack-node-externals');
module.exports = {
entry: {
server: './src/server.ts'
},
resolve: {
extensions: ['.ts', '.js'],
{
"name": "angular-universal-example",
...
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:ssr": "node dist/server.js",
"build": "run-s build:client build:aot build:server",
"build:client": "ng build -prod --build-optimizer --app 0",
"build:aot": "ng build --aot --app 1",