GithubHelp home page GithubHelp logo

angular5-with-angular8's Introduction

Web Components / Angular Elements

Useful things: https://blog.nrwl.io/5-reasons-to-use-angular-elements-390c9a629f89

Video: 'I won't go in details - you have a link on my website with a full description of everything' 'This video will show you what can be done' 'The final result will be this view' Flow: Create one Angular 5 application, one Angular 8 Application, and one React Application. Inject them all in a static index.html file and / or inject them all into Angular 5 application.

Joining Files: npm install --save-dev concat fs-extra

STEPS FOR BUILDING A WEB COMPONENT IN ANGULAR

  1. In app.module.ts convert bootstrap to entryComponents
 constructor(private injector: Injector) {}

 ngDoBootstrap() {
   const el = createCustomElement(AppComponent, {injector: this.injector});
   customElements.define('angular-eight-component', el);
 }
}
  1. npm install --save-dev concat fs-extra
  2. In package Json: "build:elements": "ng build --prod --output-hashing none && node elements-build.js",
  3. create elements-build.js in root folder and add this
const fs = require('fs-extra');
const concat = require('concat');

(async function build() {
// INSTEAD OF /Angular8/ USE YOUR PROJECT NAME OR YOUR CUSTOM DIST LOCATION
  const files = [
    './dist/Angular8/runtime-es2015.js', 
    './dist/Angular8/polyfills-es2015.js',
    './dist/Angular8/main-es2015.js'
  ];

  await fs.ensureDir('elements');
  await concat(files, 'elements/Angular8.js');
  await fs.copyFile(
    './dist/Angular8/styles.css',
    'elements/styles.css'
  );
})();

STEPS FOR INTEGRATING A WEBCOMPONENT IN ANGULAR

  1. Put the built files in assets of Angular 5 app
  2. add schemas: [CUSTOM_ELEMENTS_SCHEMA] to AppModule
  3. Do ng eject
  4. Delete every reference of CommonsChunkPlugin

ISSUE: Loading Webpack 4 in Webpack 2/3 App

https://forum.vuejs.org/t/error-when-loading-vue-on-a-webpage-that-uses-webpack-3/48955

https://stackoverflow.com/questions/39187556/angular-cli-where-is-webpack-config-js-file-new-angular6-does-not-support-ng-e

I had to disable code splitting in vue.config.js and it worked fine

webpack/webpack#8247 https://medium.com/@cliffers/how-to-run-multiple-webpack-instances-on-the-same-page-and-avoid-any-conflicts-4e2fe0f016d1

Do ng eject to eject the webpack.config.js from angular-cli

angular5-with-angular8's People

Contributors

dinohorvat avatar angular-cli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.