Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fary-vue-ssr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fary-vue-ssr

vue server side rendering

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

fary-vue-ssr

这是一个用来处理vue服务端渲染的Koa中间件

Usage

安装:

npm i fary-vue-ssr -S

使用:

const Koa = require('koa')
const faryVueSSR = require('fary-vue-ssr')

const app = new Koa()
app.use(faryVueSSR(options))

options

ssr: boolean

是否启用服务端渲染

serverBundle: object | function

vue-server-renderer中使用的模块,可以在webpack中使用vue-ssr-webpack-plugin生成。

该参数还可以传入一个方法,返回一个Promise,Promise中resolve需要使用的bundle信息

clientManifest: object | function

vue-server-renderer配置中对应的clientManifest内容,可以由vue-server-renderer/client-plugin生成。

该参数还可以传入一个方法,返回一个Promise,Promise中resolve需要使用的manifest信息

template: string | function

渲染内容时用到的模板文件,中间件使用ejs进行渲染,渲染参数如下:

{
  style: string, // 行内样式
  scripts: string, // 客户端javascripts,需要clientManifest
  title: string, // 从路由配置的meta中读取
  meta: object, // 路由配置的meta
  appString: string, // 服务端渲染的html内容
  initialState: object, // store的state
  initialLocalState: object, // 使用的localData
  preLoadAndFetch: string, // 预加载的静态文件,需要clientManifest
}

exclude: RegExp

不需要使用服务端渲染的路由

cache: boolean | object | function

如果为true,使用LRU缓存,object和function则为自定义的缓存配置

runInNewContext: boolean

是否每次都在新的执行环境执行,为true较为消耗性能,如果能保证js代码不会修改global内容,可以选择设置为false

directives: object

请参考这里

Keywords

FAQs

Package last updated on 12 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc