monkeytype/frontend/webpack/config.base.js
Jack 3e0be2e210
refactor: replace select2 with slim-select (#5065)
* i cant figure this oooout

* fix: closing commandline causing settings page update

* remove log

* fix event looping issues
rerendering selects when updating settings

* remove comment

* move section back to where it should be

* update styling

* move redrawing to settings group

* no need to save to a variable

* types

* fix styles

* search placeholder

* fix structure

* fix styles

* using slim for the rest of selects

* disabled styling

* use slim

* styling

* use slim

* multi select styling

* use slim

* use slim

* use slim

* use slim

* remove everything else related to select2

* last select2 mention

* comment

* fix(settings page): font family buttons not working

* fix: input indicators remaining visible after leaving the login page (underscoore) (#5062)

* chore: update node version to 18.19.1 (#5060)

* impr(quote): add Code C quotes (penguin-teal) (#5053)

* fix: question mark appearing next to unrated quotes

* removed unnecessary link

---------

Co-authored-by: Ajay kumar <ajaykumar.bit.1995@gmail.com>
Co-authored-by: Christian Fehmer <fehmer@users.noreply.github.com>
Co-authored-by: penguin-teal <130006737+penguin-teal@users.noreply.github.com>
2024-02-17 12:12:15 +01:00

131 lines
3.3 KiB
JavaScript

/* eslint-disable @typescript-eslint/no-var-requires */
const { resolve } = require("path");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
let circularImports = 0;
const htmlWebpackPlugins = [
"terms-of-service",
"security-policy",
"privacy-policy",
"email-handler",
].map((name) => {
return new HtmlWebpackPlugin({
filename: `${name}.html`,
template: resolve(__dirname, `../static/${name}.html`),
inject: false,
});
});
/** @type { import('webpack').Configuration } */
const BASE_CONFIG = {
entry: {
monkeytype: resolve(__dirname, "../src/ts/index.ts"),
},
resolve: { extensions: [".ts", ".js"] },
output: {
publicPath: "/",
filename: "./js/[name].[chunkhash:8].js",
path: resolve(__dirname, "../public/"),
clean: true,
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" },
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
url: false,
importLoaders: 2,
sourceMap: true,
},
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
],
},
optimization: {
splitChunks: {
chunks: "all",
minChunks: 1,
maxAsyncRequests: 30,
maxInitialRequests: 30,
enforceSizeThreshold: 50000,
cacheGroups: {
defaultVendors: {
name: "vendor",
test: /[\\/]node_modules[\\/]/,
priority: -10,
reuseExistingChunk: true,
},
},
},
},
plugins: [
new CircularDependencyPlugin({
exclude: /node_modules/,
include: /./,
failOnError: true,
allowAsyncCycles: false,
cwd: process.cwd(),
onStart() {
circularImports = 0;
},
onDetected({ paths }) {
circularImports++;
const joinedPaths = paths.join("\u001b[31m -> \u001b[0m");
console.log(`\u001b[31mCircular import found: \u001b[0m${joinedPaths}`);
},
onEnd() {
const colorCode = circularImports === 0 ? 32 : 31;
const countWithColor = `\u001b[${colorCode}m${circularImports}\u001b[0m`;
console.log(`Found ${countWithColor} circular imports`);
},
}),
new CopyPlugin({
patterns: [
{
from: resolve(__dirname, "../static"),
to: "./",
globOptions: {
ignore: ["**/static/*.html"],
},
},
],
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jQueryColor: "jquery-color",
jQueryEasing: "jquery.easing",
}),
new HtmlWebpackPlugin({
filename: "./index.html",
template: resolve(__dirname, "../static/main.html"),
inject: "body",
}),
...htmlWebpackPlugins,
new MiniCssExtractPlugin({
filename: "./css/style.[chunkhash:8].css",
}),
],
};
module.exports = BASE_CONFIG;