]> Untitled Git - lemmy-ui.git/blobdiff - webpack.config.js
Fixing timezone issue with date-fns. Fixes #1680 (#1681)
[lemmy-ui.git] / webpack.config.js
index fd210f050038ab4535dfc7fba25ce2d3c214d4b9..a2b31d04383f752d93d99a739fd9fad42ab044c8 100644 (file)
@@ -1,11 +1,12 @@
 const webpack = require("webpack");
+const path = require("path");
 const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 const nodeExternals = require("webpack-node-externals");
 const CopyPlugin = require("copy-webpack-plugin");
 const RunNodeWebpackPlugin = require("run-node-webpack-plugin");
-const merge = require("lodash/merge");
+const merge = require("lodash.merge");
 const { ServiceWorkerPlugin } = require("service-worker-webpack");
-const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
+
 const banner = `
   hash:[contentHash], chunkhash:[chunkhash], name:[name], filebase:[base], query:[query], file:[file]
   Source code: https://github.com/LemmyNet/lemmy-ui
@@ -20,8 +21,11 @@ const base = {
     hashFunction: "xxhash64",
   },
   resolve: {
-    plugins: [new TsconfigPathsPlugin()],
     extensions: [".js", ".jsx", ".ts", ".tsx"],
+    alias: {
+      "@": path.resolve(__dirname, "src/"),
+      "@utils": path.resolve(__dirname, "src/shared/utils/"),
+    },
   },
   performance: {
     hints: false,
@@ -92,6 +96,7 @@ const createClientConfig = (_env, mode) => {
     entry: "./src/client/index.tsx",
     output: {
       filename: "js/client.js",
+      publicPath: "/static/",
     },
     plugins: [
       ...base.plugins,
@@ -102,7 +107,7 @@ const createClientConfig = (_env, mode) => {
             "/": "/static/",
           },
           cacheId: "lemmy",
-          include: [/(assets|styles)\/.+\..+|client\.js$/g],
+          include: [/(assets|styles|js)\/.+\..+$/g],
           inlineWorkboxRuntime: true,
           runtimeCaching: [
             {
@@ -150,11 +155,10 @@ const createClientConfig = (_env, mode) => {
     ],
   });
 
-  if (mode === "development") {
-    // config.cache = {
-    //   type: "filesystem",
-    //   name: "client",
-    // };
+  if (mode === "none") {
+    const BundleAnalyzerPlugin =
+      require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
+    config.plugins.push(new BundleAnalyzerPlugin());
   }
 
   return config;