typescript: Type webpack.config.ts correctly.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-11-04 14:37:12 -08:00 committed by Tim Abbott
parent aad99ce951
commit de4685441c
5 changed files with 78 additions and 5 deletions

View File

@ -71,8 +71,12 @@
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@types/html-minifier": "^3.5.3",
"@types/jquery": "^3.3.31",
"@types/mini-css-extract-plugin": "^0.8.0",
"@types/node": "^12.0.7",
"@types/optimize-css-assets-webpack-plugin": "^5.0.1",
"@types/terser-webpack-plugin": "^1.2.1",
"@types/underscore": "^1.8.18",
"@types/webpack": "^4.4.32",
"@types/webpack-dev-server": "^3.1.6",

View File

@ -0,0 +1,17 @@
import { Plugin } from "webpack";
declare namespace BundleTracker {
interface Options {
path?: string;
filename?: string;
publicPath?: string;
logTime?: boolean;
}
}
// eslint-disable-next-line no-redeclare
declare class BundleTracker extends Plugin {
constructor(options?: BundleTracker.Options);
}
export = BundleTracker;

View File

@ -11,7 +11,7 @@ import TerserPlugin from 'terser-webpack-plugin';
import _webpackDevServer from 'webpack-dev-server';
import webpack from 'webpack';
const assets = require('./webpack.assets.json');
const assets: { [name: string]: string[] } = require('./webpack.assets.json');
export default (env?: string): webpack.Configuration[] => {
const production: boolean = env === "production";
@ -149,7 +149,7 @@ export default (env?: string): webpack.Configuration[] => {
// is fixed.
new OptimizeCssAssetsPlugin({
cssProcessor: {
process: async (css, options) => {
async process(css, options: any) {
const filename = basename(options.to);
const result = await new CleanCss(options).minify({
[filename]: {
@ -239,7 +239,7 @@ export default (env?: string): webpack.Configuration[] => {
if (!production) {
// Out JS debugging tools
for (const name of Object.keys(config.entry)) {
config.entry[name].push('./static/js/debug.js');
assets[name].push('./static/js/debug.js');
}
config.devServer = {
clientLogLevel: "error",

View File

@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/03/01/zulip-2-0-relea
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = '62.1'
PROVISION_VERSION = '62.2'

View File

@ -848,6 +848,13 @@
"@types/connect" "*"
"@types/node" "*"
"@types/clean-css@*":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@types/clean-css/-/clean-css-4.2.1.tgz#cb0134241ec5e6ede1b5344bc829668fd9871a8d"
integrity sha512-A1HQhQ0hkvqqByJMgg+Wiv9p9XdoYEzuwm11SVo1mX2/4PSdhjcrUlilJQoqLscIheC51t1D5g+EFWCXZ2VTQQ==
dependencies:
"@types/node" "*"
"@types/connect-history-api-fallback@*":
version "1.3.3"
resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.3.tgz#4772b79b8b53185f0f4c9deab09236baf76ee3b4"
@ -899,6 +906,15 @@
"@types/minimatch" "*"
"@types/node" "*"
"@types/html-minifier@^3.5.3":
version "3.5.3"
resolved "https://registry.yarnpkg.com/@types/html-minifier/-/html-minifier-3.5.3.tgz#5276845138db2cebc54c789e0aaf87621a21e84f"
integrity sha512-j1P/4PcWVVCPEy5lofcHnQ6BtXz9tHGiFPWzqm7TtGuWZEfCHEP446HlkSNc9fQgNJaJZ6ewPtp2aaFla/Uerg==
dependencies:
"@types/clean-css" "*"
"@types/relateurl" "*"
"@types/uglify-js" "*"
"@types/http-proxy-middleware@*":
version "0.19.3"
resolved "https://registry.yarnpkg.com/@types/http-proxy-middleware/-/http-proxy-middleware-0.19.3.tgz#b2eb96fbc0f9ac7250b5d9c4c53aade049497d03"
@ -932,6 +948,13 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==
"@types/mini-css-extract-plugin@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@types/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#6a5d3459d40cb51f14059e9aa410c9e970656103"
integrity sha512-L7OKmXudo048RMw/NeLjJMNRAbyXG76b3uGZ49OKe03imYEplx0JzcM0goVNc7X1IeESf2Bk9RP+tS1U3OSmVg==
dependencies:
"@types/webpack" "*"
"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@ -942,6 +965,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f"
integrity sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==
"@types/optimize-css-assets-webpack-plugin@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@types/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.1.tgz#1f437ef9ef937b393687a8819be2d2fddc03b069"
integrity sha512-qyi5xmSl+DTmLFtVtelhso3VnNQYxltfgMa+Ed02xqNZCZBD0uYR6i64FmcwfieDzZRdwkJxt9o2JHq/5PBKQg==
dependencies:
"@types/webpack" "*"
"@types/q@^1.5.1":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
@ -952,6 +982,11 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
"@types/relateurl@*":
version "0.2.28"
resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6"
integrity sha1-a9p9uGU/piZD9e5p6facEaOS46Y=
"@types/serve-static@*":
version "1.13.3"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1"
@ -975,6 +1010,14 @@
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==
"@types/terser-webpack-plugin@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-1.2.1.tgz#02c2cacd7769c533cbdac28dd7610c24e46b5c95"
integrity sha512-5mzQulZabFsqiLh0PhJdccIKqpd5535UYpZ+Skugz8kPzZdajMMYBRKQSzM1KOkZ42NwLxbZSzQp6xKtaq46Gg==
dependencies:
"@types/webpack" "*"
terser "^3.16.1"
"@types/uglify-js@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
@ -10322,7 +10365,7 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"
source-map-support@^0.5.9, source-map-support@~0.5.12:
source-map-support@^0.5.9, source-map-support@~0.5.10, source-map-support@~0.5.12:
version "0.5.13"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932"
integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==
@ -11097,6 +11140,15 @@ terser-webpack-plugin@^2.1.0:
terser "^4.3.1"
webpack-sources "^1.4.3"
terser@^3.16.1:
version "3.17.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-3.17.0.tgz#f88ffbeda0deb5637f9d24b0da66f4e15ab10cb2"
integrity sha512-/FQzzPJmCpjAH9Xvk2paiWrFq+5M6aVOf+2KRbwhByISDX/EujxsK+BAvrhb6H+2rtrLCHK9N01wO014vrIwVQ==
dependencies:
commander "^2.19.0"
source-map "~0.6.1"
source-map-support "~0.5.10"
terser@^4.1.2, terser@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.1.tgz#09820bcb3398299c4b48d9a86aefc65127d0ed65"