UNPKG

@leafage/server

Version:

The React Server Side Render Framework

31 lines (27 loc) 920 B
/** * @leafage/server v1.3.2 * * Copyright (c) Leafage. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ 'use strict'; var path = require('node:path'); var toolkit = require('@leafage/toolkit'); var utils = require('../common/utils.js'); var staticPreset = function staticPreset(ctx) { var staticList = toolkit.utils.toArray(ctx.context.options.server["static"]).filter(Boolean); if (!ctx.context.options.dev && !/^https?:\/\//.test(ctx.context.options.builder.publicPath)) { staticList.push({ path: ctx.context.options.builder.publicPath, handle: path.join(ctx.context.options.dir.root, ctx.context.options.dir.dist, ctx.context.options.dir.client) }); } staticList.forEach(function (row) { return utils.useMiddleware(ctx, row); }); }; exports.staticPreset = staticPreset;