From 16f23e36a534043353fa47b7f8c3815a32826512 Mon Sep 17 00:00:00 2001 From: Andrew Pinkham Date: Wed, 14 Mar 2018 11:25:28 -0400 Subject: [PATCH 1/3] webpack: Add hash options to config --- types/webpack/index.d.ts | 8 +++++++- types/webpack/webpack-tests.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 9c9239e5ea..2277ec2867 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -134,7 +134,7 @@ declare namespace webpack { } interface Output { - /** The output directory as absolute path (required). */ + /** The output directory as absolute path. */ path?: string; /** The filename of the entry chunk as relative path inside the output.path directory. */ filename?: string; @@ -190,8 +190,14 @@ declare namespace webpack { sourcePrefix?: string; /** This option enables cross-origin loading of chunks. */ crossOriginLoading?: string | boolean; + /** The encoding to use when generating the hash, defaults to 'hex' */ + hashDigest?: 'hex' | 'latin1' | 'base64'; + /** The prefix length of the hash digest to use, defaults to 20. */ + hashDigestLength?: number; /** Algorithm used for generation the hash (see node.js crypto package) */ hashFunction?: string | ((algorithm: string, options?: any) => any); + /** An optional salt to update the hash via Node.JS' hash.update. */ + hashSalt?: string; /** An expression which is used to address the global object/scope in runtime code. */ globalObject?: string; } diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index d6bd908357..8fe0ab1e4d 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -100,7 +100,9 @@ configuration = { path: path.join(__dirname, "assets", "[hash]"), publicPath: "assets/[hash]/", filename: "output.[hash].bundle.js", - chunkFilename: "[id].[hash].bundle.js" + chunkFilename: "[id].[hash].bundle.js", + hashFunction: 'sha256', + hashDigestLength: 64, } }; From b822a843fb7c124d89ad3b4ae1a1ebc4c9186272 Mon Sep 17 00:00:00 2001 From: Andrew Pinkham Date: Wed, 14 Mar 2018 14:33:37 -0400 Subject: [PATCH 2/3] webpack v3: require output filename; add hash opts --- types/webpack/v3/index.d.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/types/webpack/v3/index.d.ts b/types/webpack/v3/index.d.ts index d6102808b6..e8a3c36c65 100644 --- a/types/webpack/v3/index.d.ts +++ b/types/webpack/v3/index.d.ts @@ -126,10 +126,10 @@ declare namespace webpack { } interface Output { - /** The output directory as absolute path (required). */ + /** The output directory as absolute path */ path?: string; - /** The filename of the entry chunk as relative path inside the output.path directory. */ - filename?: string; + /** (Required) The filename of the entry chunk as relative path inside the output.path directory. */ + filename: string; /** The filename of non-entry chunks as relative path inside the output.path directory. */ chunkFilename?: string; /** The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. */ @@ -182,6 +182,14 @@ declare namespace webpack { sourcePrefix?: string; /** This option enables cross-origin loading of chunks. */ crossOriginLoading?: string | boolean; + /** The encoding to use when generating the hash, defaults to 'hex' */ + hashDigest?: 'hex' | 'latin1' | 'base64'; + /** The prefix length of the hash digest to use, defaults to 20. */ + hashDigestLength?: number; + /** Algorithm used for generation the hash (see node.js crypto package) */ + hashFunction?: string | ((algorithm: string, options?: any) => any); + /** An optional salt to update the hash via Node.JS' hash.update. */ + hashSalt?: string; } interface BaseModule { From c0cfefc595781437b3ad6c17af6879ec498a0dbc Mon Sep 17 00:00:00 2001 From: Andrew Pinkham Date: Wed, 14 Mar 2018 14:39:17 -0400 Subject: [PATCH 3/3] webpack v3: revert filename requirement Necessary for partial configurations. --- types/webpack/v3/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack/v3/index.d.ts b/types/webpack/v3/index.d.ts index e8a3c36c65..7f943d4151 100644 --- a/types/webpack/v3/index.d.ts +++ b/types/webpack/v3/index.d.ts @@ -129,7 +129,7 @@ declare namespace webpack { /** The output directory as absolute path */ path?: string; /** (Required) The filename of the entry chunk as relative path inside the output.path directory. */ - filename: string; + filename?: string; /** The filename of non-entry chunks as relative path inside the output.path directory. */ chunkFilename?: string; /** The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. */