How to use the vue-server-renderer.createBundleRenderer function in vue-server-renderer

To help you get started, we’ve selected a few vue-server-renderer 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 leocoder351 / vue-ssr-demo / 05 / server / server.js View on Github external
const Koa = require('koa');
const Router = require('koa-router');
const serve = require('koa-static');
const path = require('path');
const fs = require('fs');
const { createBundleRenderer } = require('vue-server-renderer');
const backendApp = new Koa();
const frontendApp = new Koa();
const backendRouter = new Router();
const frontendRouter = new Router();

const serverBundle = require(path.resolve(__dirname, '../dist/vue-ssr-server-bundle.json'));
const clientManifest = require(path.resolve(__dirname, '../dist/vue-ssr-client-manifest.json'));
const template = fs.readFileSync(path.resolve(__dirname, '../dist/index.ssr.html'), 'utf-8');

const renderer = createBundleRenderer(serverBundle, {
  runInNewContext: false,
  template: template,
  clientManifest: clientManifest
});

// 后端Server
backendApp.use(serve(path.resolve(__dirname, '../dist')));

backendRouter.get('*', (ctx, next) => {
  console.log('ctx', ctx);
  console.log('url', ctx.url);

  let context = {
    url: ctx.url
  };
github easy-mock / easy-mock / middlewares / view.js View on Github external
function createRenderer (bundle, options) {
  // https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer
  return createBundleRenderer(bundle, Object.assign(options, {
    cache: LRU({
      max: 1000,
      maxAge: 1000 * 60 * 15
    }),
    // this is only needed when vue-server-renderer is npm-linked
    basedir: resolve('../dist'),
    // recommended for performance
    runInNewContext: false
  }))
}
github zhangyuang / douBanByVueSsr / build / dev-server.js View on Github external
function createRenderer (bundle, options) {
  return createBundleRenderer(bundle, Object.assign(options, {
    template,
    runInNewContext: false,
    // cache: LRU({
    //   max: 10000,
    //   maxAge: ...
    // })//启用组件缓存
  }))
}
if (isProd) {
github shimh-develop / blog-vue-springboot / blog-app / server.js View on Github external
function createRenderer(bundle, options) {
    // https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer
    return createBundleRenderer(bundle, Object.assign(options, {
        // for component caching
        cache: LRU({
            max: 1000,
            maxAge: 1000 * 60 * 15
        }),
        // this is only needed when vue-server-renderer is npm-linked
        basedir: resolve('./dist'),
        // recommended for performance
        runInNewContext: false
    }))
}
github doabit / vue-ssr-starter-kit / server.js View on Github external
function createRenderer (bundle, template) {
  // https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer
  return require('vue-server-renderer').createBundleRenderer(bundle, {
    template,
    cache: require('lru-cache')({
      max: 1000,
      maxAge: 1000 * 60 * 15
    })
  })
}
github quasarframework / quasar-cli / lib / dev-server.js View on Github external
function createRenderer (bundle, options) {
      // https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer
      return createBundleRenderer(bundle, Object.assign(options, {
        // for component caching
        cache: LRU({
          max: 1000,
          maxAge: 1000 * 60 * 15
        }),
        // recommended for performance
        runInNewContext: false
      }))
    }
github antonreshetov / vue-ssr-boilerplate / server.js View on Github external
function createRenderer (bundle, options) {
    return createBundleRenderer(bundle, Object.assign(options, {
      runInNewContext: false
    }))
  }
github HuijiFE / void-ui / build / setup-ssr.js View on Github external
function createRenderer(bundle, options) {
  return createBundleRenderer(bundle, {
    ...options,
    runInNewContext: false,
  });
}
github Narkoleptika / webpack-everything / template / server / renderer.js View on Github external
const createRenderer = (serverBundle, clientManifest, template)=> {
    return require('vue-server-renderer').createBundleRenderer(serverBundle, {
        template,
        clientManifest,
        inject: false,
        cache: require('lru-cache')({
            max: 1000,
            maxAge: 1000 * 60 * 15
        })
    })
}