123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- import { Compiler } from 'webpack';
- const path = require('path');
- const fs = require('fs');
- const zlib = require("zlib");
- export = SPIFFSUpdate;
- interface SPIFFSUpdateOptions {
- sourceFiles?: string[];
- targetFiles?: string[];
- compress?: boolean;
- }
- class SPIFFSUpdate {
- private sourceFiles: string[];
- private targetFiles: string[];
- private compress: boolean;
- constructor(options: SPIFFSUpdateOptions) {
- this.sourceFiles = options.sourceFiles || [];
- this.targetFiles = options.targetFiles || [];
- this.compress = options.compress || true;
- }
- apply(compiler: Compiler) {
- compiler.hooks.afterEmit.tapAsync('GrpcToolsNodeProtocPlugin', (compilation, callback) => {
- try {
- fs.appendFileSync('./dist/index.html.gz',
- zlib.gzipSync(fs.readFileSync('./dist/index.html'),
- {
- chunckSize: 65536,
- level: zlib.constants.Z_BEST_COMPRESSION
- })
- );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- } catch (error) {
- console.error('Error setting up grpc-tools protoc', error);
- }
- callback();
- });
- }
- }
|