Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/react-server / src / middleware / clientBundle.ts
Size: Mime:
import { resolve as pathResolve } from 'path'
import { config } from '@skava/bs'
import express from 'express'

// also this is super weird because of webpack dev server not emitting the file
const expireSettings = {
  // Cache-Control: private, max-age=604800
  maxAge: process.env.BROWSER_MAX_CACHE_AGE,
  index: false,
  // @todo
  // import { versions } from '../../../package.json'
  // lastModified: versions && versions.date,
  // index: ['vendor', 'workbox.js', 'index.js'],
  // extensions: 'js'
  // setHeaders < needed for security header types
}

// actually am super confused here...
// dist/dist/bundled/client/
// but it has index.js
// so does it resolve only index......?
// often there is no file here (o.o) < webpack dev server keeps in memory
const clientBundleOutputPath = pathResolve(
  config.get('appRootDir'),
  process.env.BUILD_CONFIG_WEB_OUTPUT_PATH
)

/**
 * Middleware to server our client bundle.
 *
 * @example
 * /usr/project-here/dist/client
 */
const staticMiddleware = express.static(clientBundleOutputPath, expireSettings)

export {
  staticMiddleware,
  staticMiddleware as clientBundle,
  clientBundleOutputPath,
}
export default staticMiddleware