项目作者: hypebeast

项目描述 :
Snowpack integration for Fastify
高级语言: JavaScript
项目地址: git://github.com/hypebeast/fastify-snowpack.git
创建时间: 2021-01-21T22:58:42Z
项目社区:https://github.com/hypebeast/fastify-snowpack

开源协议:MIT License

下载


fastify-snowpack

fastify-snowpack is a fastify plugin that add supports for using snowpack as a frontend build tool for server side rendered pages (e.g. with point-of-view).

It starts Snowpack’s dev server and processes all assets defined in your snowpack.config.js.

Supports Fastify versions 3.x.

:warning: This project is meant to be used in development environment only.

Install

  1. npm i fastify-snowpack

Usage

Require fastify-snowpack and register it as a plugin, it will add a onRequest hook.

  1. const fastify = require('fastify')();
  2. fastify
  3. .register(require('fastify-snowpack'), {
  4. // put your config here
  5. })
  6. .register(require('fastify-static'), {
  7. root: join(__dirname, 'public'),
  8. prefix: '/',
  9. })
  10. .get('/', (request, reply) => {
  11. return reply.sendFile('index.html');
  12. });
  13. fastify.listen(3000);

See ./example/server.js for a full example how to use this plugin.

Options

  • config: This option configures the Snowpack dev server. The value of config could be of different types:
    • String - set config to the path of a valid Snowpack configuration file.
    • Object - pass directly a valid Snowpack configuration.

License

See License.