$ ng g application view-todo --style=scss --prefix=view --viewEncapsulation=ShadowDom --routing=false
Last active
March 13, 2020 03:16
-
-
Save paul58914080/22bfaf7e1f90fda0ec3f63bf7c905201 to your computer and use it in GitHub Desktop.
view-todo-micro-app
$ ng g module view-todo --flat=true --project=view-todo
$ ng g component view-todo --module=view-todo --selector=view-todo --entryComponent=true --flat=true --project=create-todo
$ ng g service view-todo --project=view-todo --flat=true --project=create-todo
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
import {NgModule} from '@angular/core'; | |
import {CommonModule} from '@angular/common'; | |
import {HomeComponent} from './home.component'; | |
import {ViewTodoModule} from '../../../projects/view-todo/src/app/view-todo.module'; | |
@NgModule({ | |
declarations: [ HomeComponent ], | |
imports: [ | |
CommonModule, | |
ViewTodoModule | |
] | |
}) | |
export class HomeModule { | |
} |
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
<div class="container-fluid"> | |
<view-todo></view-todo> | |
</div> |
$ ng add @angular/elements --project=view-todo
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
import {Injector, NgModule} from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { ViewTodoComponent } from './view-todo.component'; | |
import {BrowserModule} from '@angular/platform-browser'; | |
import {createCustomElement} from '@angular/elements'; | |
@NgModule({ | |
declarations: [ViewTodoComponent], | |
imports: [ | |
CommonModule, | |
BrowserModule | |
], | |
entryComponents: [ViewTodoComponent], | |
bootstrap: [ViewTodoComponent], | |
exports: [ViewTodoComponent] | |
}) | |
export class ViewTodoModule { | |
constructor(private injector: Injector) { | |
} | |
ngDoBootstrap() { | |
const viewTodoElement = createCustomElement(ViewTodoComponent, { injector: this.injector }); | |
customElements.define('view-todo-element', viewTodoElement); | |
} | |
} |
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
const fs = require('fs-extra'); | |
const concat = require('concat'); | |
const del = require('del'); | |
(async function build() { | |
const files = [ | |
'dist/view-todo/runtime-es2015.js', | |
'dist/view-todo/polyfills-es2015.js', | |
'dist/view-todo/main-es2015.js' | |
]; | |
await del(['dist/elements/view-todo.js']); | |
await fs.ensureDir('dist/elements'); | |
await concat(files, 'dist/elements/view-todo.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
export const environment = { | |
production: false, | |
loadBootstrap: true | |
}; |
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
export const environment = { | |
production: true, | |
loadBootstrap: false | |
}; |
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
import {Injector, NgModule} from '@angular/core'; | |
import {CommonModule} from '@angular/common'; | |
import {ViewTodoComponent} from './view-todo.component'; | |
import {BrowserModule} from '@angular/platform-browser'; | |
import {createCustomElement} from '@angular/elements'; | |
import {environment} from '../environments/environment'; | |
@NgModule({ | |
declarations: [ ViewTodoComponent ], | |
imports: [ | |
CommonModule, | |
BrowserModule | |
], | |
entryComponents: [ ViewTodoComponent ], | |
bootstrap: environment.loadBootstrap ? [ ViewTodoComponent ] : [], | |
exports: [ ViewTodoComponent ] | |
}) | |
export class ViewTodoModule { | |
constructor(private injector: Injector) { | |
} | |
ngDoBootstrap() { | |
const viewTodoElement = createCustomElement(ViewTodoComponent, { injector: this.injector }); | |
customElements.define('view-todo-element', viewTodoElement); | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Web component</title> | |
</head> | |
<body> | |
<view-todo-element></view-todo-element> | |
<script type='application/javascript' src='view-todo.js'></script> | |
</body> | |
</html> |
$ npm i --save @angular-builders/custom-webpack
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
"view-todo": { | |
"projectType": "application", | |
"architect": { | |
"build": { | |
"builder": "@angular-builders/custom-webpack:browser", | |
"options": { | |
"customWebpackConfig": { | |
"path": "projects/view-todo/build/extra-webpack.config.js", | |
"mergeStrategies": { | |
"externals": "replace" | |
} | |
} | |
} | |
} | |
} | |
} |
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
module.exports = { | |
output: { | |
jsonpFunction: 'webpackJsonpViewTodo' | |
} | |
}; |
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
"micro-frontend-todo": { | |
"architect": { | |
"build": { | |
"options": { | |
"scripts": [ | |
{ | |
"input": "node_modules/document-register-element/build/document-register-element.js" | |
}, | |
"dist/elements/view-todo.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
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'todo-home', | |
templateUrl: './home.component.html', | |
styleUrls: ['./home.component.scss'] | |
}) | |
export class HomeComponent implements OnInit { | |
loadElement = false; | |
constructor() { } | |
ngOnInit() { | |
} | |
} |
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
@import url(‘https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'); |
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
@import url("https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"); |
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
@import url("https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment