How to use @nestjs/ng-universal - 10 common examples

To help you get started, we’ve selected a few @nestjs/ng-universal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github servrox / nx-ng-nest-universal / apps / nest-test-app / webpack.server.config.js View on Github external
const path = require('path');
const webpack = require('webpack');
const WebpackConfigFactory = require('@nestjs/ng-universal')
  .WebpackConfigFactory;

const config = WebpackConfigFactory.create(webpack, {
  // Nest server for SSR
  server: './apps/nest-test-app/src/main.ts'
});
config.output = {
  // Puts the output at the root of the dist folder
  path: path.join(__dirname, '../../dist/apps/ng-test-app-server'),
  filename: '[name].js'
};
config.plugins = [
  new webpack.ContextReplacementPlugin(
    // fixes WARNING Critical dependency: the request of a dependency is an expression
    /(.+)?angular(\\|\/)core(.+)?/,
    path.join(__dirname, 'apps/ng-test-app/src'), // location of your src
github servrox / nx-ng-nest-universal / apps / nest-test-app / webpack.server.config.js View on Github external
const path = require('path');
const webpack = require('webpack');
const WebpackConfigFactory = require('@nestjs/ng-universal')
  .WebpackConfigFactory;

const config = WebpackConfigFactory.create(webpack, {
  // Nest server for SSR
  server: './apps/nest-test-app/src/main.ts'
});
config.output = {
  // Puts the output at the root of the dist folder
  path: path.join(__dirname, '../../dist/apps/ng-test-app-server'),
  filename: '[name].js'
};
config.plugins = [
  new webpack.ContextReplacementPlugin(
    // fixes WARNING Critical dependency: the request of a dependency is an expression
    /(.+)?angular(\\|\/)core(.+)?/,
    path.join(__dirname, 'apps/ng-test-app/src'), // location of your src
    {} // a map of your routes
  ),
  new webpack.ContextReplacementPlugin(
github kamilmysliwiec / universal-nest / prerender.ts View on Github external
import { applyDomino } from '@nestjs/ng-universal';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { ROUTES } from './static.paths';

// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();

const BROWSER_FOLDER = join(process.cwd(), 'browser');

// Load the index.html file containing references to your application bundle.
const indexPath = join('browser', 'index.html');
// Ensure that we mock Window|Document etc
applyDomino(global, indexPath);

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
  AppServerModuleNgFactory,
  LAZY_MODULE_MAP,
} = require('./dist/server/main');

let previousRender = Promise.resolve();

// Iterate each route path
ROUTES.forEach(route => {
  const fullPath = join(BROWSER_FOLDER, route);

  // Make sure the directory structure is there
  if (!existsSync(fullPath)) {
    mkdirSync(fullPath);
github nestjs / ng-universal / schematics / install / files / root / webpack.server.config.js View on Github external
const webpack = require('webpack');
const WebpackConfigFactory = require('@nestjs/ng-universal')
  .WebpackConfigFactory;

module.exports = WebpackConfigFactory.create(webpack, {
  // Nest server for SSR
  server: './server/main.ts'
});
github nestjs / ng-universal / schematics / install / files / root / webpack.server.config.js View on Github external
const webpack = require('webpack');
const WebpackConfigFactory = require('@nestjs/ng-universal')
  .WebpackConfigFactory;

module.exports = WebpackConfigFactory.create(webpack, {
  // Nest server for SSR
  server: './server/main.ts'
});
github servrox / nx-ng-nest-universal / apps / nest-test-app / src / app / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';

import { AppController } from './app.controller';
import { AppService } from './app.service';

const BROWSER_DIR = join(process.cwd(), 'dist', 'apps', 'ng-test-app');
applyDomino(global, join(BROWSER_DIR, 'index.html'));

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: BROWSER_DIR,
      bundle: require('../../../../dist/apps/ng-test-app-server/main'),
      liveReload: true
    })
  ],
  controllers: [AppController],
  providers: [AppService]
})
export class AppModule {}
github servrox / nx-ng-nest-universal / apps / nest-test-app / src / app / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';

import { AppController } from './app.controller';
import { AppService } from './app.service';

const BROWSER_DIR = join(process.cwd(), 'dist', 'apps', 'ng-test-app');
applyDomino(global, join(BROWSER_DIR, 'index.html'));

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: BROWSER_DIR,
      bundle: require('../../../../dist/apps/ng-test-app-server/main'),
      liveReload: true
    })
  ],
  controllers: [AppController],
  providers: [AppService]
})
export class AppModule {}
github kamilmysliwiec / universal-nest / server / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';
import { AppController } from './app.controller';

const BROWSER_DIR = join(process.cwd(), 'dist/browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: BROWSER_DIR,
      bundle: require('../server/main'),
      liveReload: true,
    }),
  ],
  controllers: [AppController],
})
export class ApplicationModule {}
github ForetagInc / fullstack-ts-boilerplate / apps / ssr / src / app.module.ts View on Github external
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AngularUniversalModule } from '@nestjs/ng-universal';
import { transferStateMiddleware } from '@foretag/transfer-state';

import { webFolder, webServerFolder } from './utils';

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: webFolder(),
      bundle: require(webServerFolder('main.js')),
    }),
  ],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    return consumer
      .apply(transferStateMiddleware)
      .exclude('assets')
      .forRoutes('*');
  }
}
github servrox / nx-ng-nest-universal / server / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';

const BROWSER_DIR = join(process.cwd(), 'dist', 'browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      viewsPath: BROWSER_DIR,
      bundle: require('../server/main'),
      liveReload: true
    })
  ]
})
export class ApplicationModule {}

@nestjs/ng-universal

Nest - modern, fast, powerful node.js web framework (@ng-universal)

MIT
Latest version published 1 year ago

Package Health Score

49 / 100
Full package analysis

Similar packages