Socket
Book a DemoInstallSign in
Socket

webpack-fastify-hmr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-fastify-hmr

A Fastify plugin for serving files emitted by Webpack.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

webpack-fastify-hmr

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

A Fastify plugin for serving files emitted by Webpack.

Setup

import webpack from 'webpack';
import {
  fastifyWebpack,
} from 'fastify-webpack';

const compiler = webpack();

void app.register(fastifyWebpack, {
  compiler,
});

Response Compression

This plugin is compatible with compression-webpack-plugin, i.e. This plugin will serve compressed files if the following conditions are true:

  • Your outputs include compressed file versions (either .br or .gz)
  • Request includes a matching accept-encoding header

Example compression-webpack-plugin configuration:

new CompressionPlugin({
  algorithm: 'brotliCompress',
  deleteOriginalAssets: false,
  filename: '[path][base].br',
  compressionOptions: {
    level: zlib.constants.BROTLI_MIN_QUALITY,
  },
  minRatio: 0.8,
  test: /\.(js|css|html|svg)$/,
  threshold: 10_240,
})

Note: You may also try using fastify-compress, however, beware of the outstanding issue that may cause the server to crash (fastify-compress#215).

Difference from webpack-dev-server

All of the above are relatively straightforward to implement, however, I didn't have a use-case for them. If you have a use-case, please raise a PR.

Debugging

This project uses roarr logger to output the program's state.

Export ROARR_LOG=true environment variable to enable log printing to stdout.

Use roarr-cli program to pretty-print the logs.

Keywords

fastify

FAQs

Package last updated on 17 Mar 2022

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