A Fastify plugin for serving files emitted by Webpack.
import webpack from 'webpack';
import {
fastifyWebpack,
} from 'fastify-webpack';
const compiler = webpack();
void app.register(fastifyWebpack, {
compiler,
});
This plugin is compatible with compression-webpack-plugin, i.e. This plugin will serve compressed files if the following conditions are true:
.br or .gz)accept-encoding headerExample 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).
serverSideRenderwriteToDiskMultiCompilerAccept-RangesAll 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.
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.