From 5e762d799d6779106c33b899ed71839501b1443a Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:18:30 +0200 Subject: [PATCH 1/5] Add compression-webpack-plugin --- .../compression-webpack-plugin-tests.ts | 14 +++++++ compression-webpack-plugin/index.d.ts | 40 +++++++++++++++++++ compression-webpack-plugin/tsconfig.json | 20 ++++++++++ compression-webpack-plugin/tslint.json | 7 ++++ 4 files changed, 81 insertions(+) create mode 100644 compression-webpack-plugin/compression-webpack-plugin-tests.ts create mode 100644 compression-webpack-plugin/index.d.ts create mode 100644 compression-webpack-plugin/tsconfig.json create mode 100644 compression-webpack-plugin/tslint.json diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts new file mode 100644 index 0000000000..4ee93c78b7 --- /dev/null +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -0,0 +1,14 @@ +import { Configuration } from 'webpack' +import * as CompressionPlugin from 'compression-webpack-plugin' + +const c: Configuration = { + plugins: [ + new CompressionPlugin({ + asset: "[path].gz[query]", + algorithm: "gzip", + test: /\.js$|\.html$/, + threshold: 10240, + minRatio: 0.8 + }) + ] +}; diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..cf65f55300 --- /dev/null +++ b/compression-webpack-plugin/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for compression-webpack-plugin 0.3.2 +// Project: https://github.com/webpack-contrib/compression-webpack-plugin +// Definitions by: Anton Kandybo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'webpack'; + +export = CompressionPlugin; + +declare class CompressionPlugin extends Plugin { + constructor(options?: CompressionPlugin.Options); +} + +declare namespace CompressionPlugin { + export interface Options { + asset?: string; + algorithm?: string; + test?: RegExp | RegExp[]; + regExp?: RegExp | RegExp[]; + threshold?: number; + minRatio?: number; + + // zopfli options + verbose?: boolean; + verbose_more?: boolean; + numiterations?: number; + blocksplitting?: boolean; + blocksplittinglast?: boolean; + blocksplittingmax?: number; + + // zlib options + level?: number; + flush?: number; + chunkSize?: number; + windowBits?: number; + memLevel?: number; + strategy?: number; + dictionary?: any; + } +} diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..f9c84d64f8 --- /dev/null +++ b/compression-webpack-plugin/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "compression-webpack-plugin-tests.ts" + ] +} diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json new file mode 100644 index 0000000000..02312e1c7d --- /dev/null +++ b/compression-webpack-plugin/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "dt-header": false + } + } + \ No newline at end of file From 972fc4d5606f96fc50b01bf2578f2cff786dd3a7 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:26:47 +0200 Subject: [PATCH 2/5] Added es6 lib --- compression-webpack-plugin/tsconfig.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json index f9c84d64f8..70383d3658 100644 --- a/compression-webpack-plugin/tsconfig.json +++ b/compression-webpack-plugin/tsconfig.json @@ -2,6 +2,9 @@ "compilerOptions": { "module": "commonjs", "target": "es6", + "lib": [ + "es6" + ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From b00b86d7197ed3217557fc6e88657c19a8b67f55 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 09:57:24 +0200 Subject: [PATCH 3/5] Enable dt-header tslint rule --- compression-webpack-plugin/tslint.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json index 02312e1c7d..70cee1ba88 100644 --- a/compression-webpack-plugin/tslint.json +++ b/compression-webpack-plugin/tslint.json @@ -1,7 +1,4 @@ { - "extends": "../tslint.json", - "rules": { - "dt-header": false - } - } + "extends": "../tslint.json" +} \ No newline at end of file From 9e069e784e7a5bc12f1abacd71b319a9f02f1c8b Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:13:16 +0200 Subject: [PATCH 4/5] Using require syntax in tests --- .../compression-webpack-plugin-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts index 4ee93c78b7..3939bf5847 100644 --- a/compression-webpack-plugin/compression-webpack-plugin-tests.ts +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -1,5 +1,5 @@ -import { Configuration } from 'webpack' -import * as CompressionPlugin from 'compression-webpack-plugin' +import { Configuration } from 'webpack'; +import CompressionPlugin = require('compression-webpack-plugin'); const c: Configuration = { plugins: [ From 911335f7fe972e349f402ce229627095b38ab020 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:14:53 +0200 Subject: [PATCH 5/5] Remove patch version --- compression-webpack-plugin/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts index cf65f55300..536a77b8e9 100644 --- a/compression-webpack-plugin/index.d.ts +++ b/compression-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for compression-webpack-plugin 0.3.2 +// Type definitions for compression-webpack-plugin 0.3 // Project: https://github.com/webpack-contrib/compression-webpack-plugin // Definitions by: Anton Kandybo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped