-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
Description
在上一个版本中,使用此组件,用户需要在项目根目录新增 sls.js
文件,现在组件帮忙处理了,所以不需要用户处理了。默认 sls.js
代码如下:
const express = require('express')
const { Nuxt } = require('nuxt')
const pkg = require('./package.json')
const app = express()
// Import and Set Nuxt.js options
const config = require('./nuxt.config.js')
config.dev = false
async function createServer() {
// Init Nuxt.js
const nuxt = new Nuxt(config)
await nuxt.ready()
// Give nuxt middleware to express
app.use(nuxt.render)
// define binary type for response
// if includes, will return base64 encoded, very useful for images
app.binaryTypes = pkg.binaryTypes || ['*/*']
return app
}
module.exports = createServer
当然,如果需要自定义路由服务,可以在项目根目录下创建 sls.js
文件,进行自定义。