mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
webpack: Run with node --experimental-strip-types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
a70babaec4
commit
45de69465a
@@ -1,6 +1,7 @@
|
||||
/// <reference types="webpack-dev-server" />
|
||||
|
||||
import path from "node:path";
|
||||
import * as url from "node:url";
|
||||
|
||||
import type {ZopfliOptions} from "@gfx/zopfli";
|
||||
import {gzip} from "@gfx/zopfli";
|
||||
@@ -8,13 +9,12 @@ import CompressionPlugin from "compression-webpack-plugin";
|
||||
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
||||
import {DefinePlugin} from "webpack";
|
||||
import type webpack from "webpack";
|
||||
import webpack from "webpack";
|
||||
import BundleTracker from "webpack-bundle-tracker";
|
||||
|
||||
import DebugRequirePlugin from "./debug-require-webpack-plugin.ts";
|
||||
import assets from "./webpack.assets.json";
|
||||
import dev_assets from "./webpack.dev-assets.json";
|
||||
import assets from "./webpack.assets.json" with {type: "json"};
|
||||
import dev_assets from "./webpack.dev-assets.json" with {type: "json"};
|
||||
|
||||
const config = (
|
||||
env: {minimize?: true; puppeteer_tests?: true; ZULIP_VERSION?: string} = {},
|
||||
@@ -24,23 +24,23 @@ const config = (
|
||||
|
||||
const baseConfig: webpack.Configuration = {
|
||||
mode: production ? "production" : "development",
|
||||
context: __dirname,
|
||||
context: import.meta.dirname,
|
||||
cache: {
|
||||
type: "filesystem",
|
||||
buildDependencies: {
|
||||
config: [__filename],
|
||||
config: [import.meta.filename],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const plugins: webpack.WebpackPluginInstance[] = [
|
||||
new DefinePlugin({
|
||||
new webpack.DefinePlugin({
|
||||
DEVELOPMENT: JSON.stringify(!production),
|
||||
ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"),
|
||||
}),
|
||||
new DebugRequirePlugin(),
|
||||
new BundleTracker({
|
||||
path: path.join(__dirname, production ? ".." : "../var"),
|
||||
path: path.join(import.meta.dirname, production ? ".." : "../var"),
|
||||
filename: production ? "webpack-stats-production.json" : "webpack-stats-dev.json",
|
||||
}),
|
||||
// Extract CSS from files
|
||||
@@ -79,17 +79,17 @@ const config = (
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: require.resolve("./src/zulip_test.ts"),
|
||||
test: path.resolve(import.meta.dirname, "src/zulip_test.ts"),
|
||||
loader: "expose-loader",
|
||||
options: {exposes: "zulip_test"},
|
||||
},
|
||||
{
|
||||
test: require.resolve("./debug-require.js"),
|
||||
test: path.resolve(import.meta.dirname, "debug-require.js"),
|
||||
loader: "expose-loader",
|
||||
options: {exposes: "require"},
|
||||
},
|
||||
{
|
||||
test: require.resolve("jquery"),
|
||||
test: url.fileURLToPath(import.meta.resolve("jquery")),
|
||||
loader: "expose-loader",
|
||||
options: {exposes: ["$", "jQuery"]},
|
||||
},
|
||||
@@ -119,15 +119,15 @@ const config = (
|
||||
{
|
||||
test: /\.[cm]?[jt]s$/,
|
||||
include: [
|
||||
path.resolve(__dirname, "shared/src"),
|
||||
path.resolve(__dirname, "src"),
|
||||
path.resolve(import.meta.dirname, "shared/src"),
|
||||
path.resolve(import.meta.dirname, "src"),
|
||||
],
|
||||
loader: "babel-loader",
|
||||
},
|
||||
// regular css files
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: path.resolve(__dirname, "styles"),
|
||||
exclude: path.resolve(import.meta.dirname, "styles"),
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
@@ -141,7 +141,7 @@ const config = (
|
||||
// PostCSS loader
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: path.resolve(__dirname, "styles"),
|
||||
include: path.resolve(import.meta.dirname, "styles"),
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
{
|
||||
@@ -198,7 +198,7 @@ const config = (
|
||||
],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "../static/webpack-bundles"),
|
||||
path: path.resolve(import.meta.dirname, "../static/webpack-bundles"),
|
||||
publicPath: "auto",
|
||||
filename: production ? "[name].[contenthash].js" : "[name].js",
|
||||
assetModuleFilename: production
|
||||
@@ -272,7 +272,7 @@ const config = (
|
||||
"katex-cli": "shebang-loader!katex/cli",
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "../static/webpack-bundles"),
|
||||
path: path.resolve(import.meta.dirname, "../static/webpack-bundles"),
|
||||
},
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user