joinlemmy-site/webpack.config.js
Dessalines d17c4d7d2f
New tailwind-based joinlemmy-site (#243)
* Starting on new tailwind based joinlemmy-site.

* Formatting fix.

* Adding follow communities block.

* Adding a few more blocks.

* Finishing up blocks.

* Adding a few more pages.

* Adding apps page.

* Almost done with donation page.

* Adding most of instances page.

* Trying to fix CI 1.

* Adding navbar and footer.

* Adding bottom spacer.

* Finishing up more info modal.

* Adding icons to main page.

* Eruda only in development mode.

* Finishing up main page, starting to work on recs.

* Adding main images.

* Adding images 2.

* Starting to add filters.

* Finishing up helper modal.

* Adding topic icons.

* Adding more instances.

* Fixing recommended.

* Forgot to add instance picker.

* Adding world background image.

* Adding alexandrite.

* Adding funding goal block.

* Fix dockerfile.

* Upgrading deps.

* Fixing package json.

* Updating coders, sponsors.

* Fixing mobile margins.

* Fixing navbar auto-close when clicked.

* Removing todo.

* Removing some useless instance helper links.

* Fixing news titling.

* Addressing PR comments.

* Updating instance stats.

* Fixing class -> className

* Fixing sm:max directives.

* Make instance images links to their sites.

* Use ubuntu font.

* Addressing PR comments.

* Adding a few more android apps.

* Adding thunder and combustible apps.

* Fixing z index.

* Add a warning alert for closed source apps.

* Adding MLMYM app. Fixes #213

* Fixing i18n key.

* Adding QR codes for cryptos. Fixes #219

* Addressing PR comments.

* Fixing news preview.

* Adding registration mode to details modal. Fixes #153

* Filter out bot instances.

* Using glide carousel.

* Adding glide min css.

* Adding donation platform fetching. Fixes #248

* Prettying glide css.

* Change dev goal to 3

* Adding sign up button.

* Minifying docker image.

* Removing sortpack.
2023-10-31 09:31:03 -04:00

99 lines
2.3 KiB
JavaScript

const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
const CopyPlugin = require("copy-webpack-plugin");
const RunNodeWebpackPlugin = require("run-node-webpack-plugin");
const { merge } = require("lodash");
const banner = `
hash:[contentHash], chunkhash:[chunkhash], name:[name], filebase:[base], query:[query], file:[file]
Source code: https://github.com/LemmyNet/joinlemmy-site
Created by dessalines
@license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
`;
const base = {
output: {
filename: "js/server.js",
publicPath: "/",
},
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
performance: {
hints: false,
},
module: {
rules: [
{
test: /\.(js|jsx|tsx|ts)$/, // All ts and tsx files will be process by
exclude: /node_modules/, // ignore node_modules
loader: "babel-loader",
},
// Due to some weird babel issue: https://github.com/webpack/webpack/issues/11467
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
plugins: [
new CopyPlugin({
patterns: [{ from: "./src/assets", to: "./assets" }],
}),
new webpack.BannerPlugin({
banner,
}),
],
};
const createServerConfig = (_env, mode) => {
const config = merge({}, base, {
mode,
entry: "./src/server/index.tsx",
output: {
filename: "js/server.js",
},
target: "node",
externals: [nodeExternals(), "inferno-helmet"],
});
if (mode === "development") {
config.cache = {
type: "filesystem",
name: "server",
};
config.plugins.push(
new RunNodeWebpackPlugin({
runOnlyInWatchMode: true,
}),
);
}
return config;
};
const createClientConfig = (_env, mode) => {
const config = merge({}, base, {
mode,
entry: "./src/client/index.tsx",
output: {
filename: "js/client.js",
},
});
if (mode === "development") {
config.cache = {
type: "filesystem",
name: "client",
};
}
return config;
};
module.exports = (env, properties) => [
createServerConfig(env, properties.mode || "development"),
createClientConfig(env, properties.mode || "development"),
];