monkeytype/frontend/webpack/config.prod.js
Evan cbca2a8957
Remove JavaScript Compilation from the Frontend (#2764) Ferotiq
* remove javascript compilation from frontend

* add dat back

* I'm going risky

* regen and put the type back
2022-03-25 13:19:21 +01:00

80 lines
2.1 KiB
JavaScript

const { merge } = require("webpack-merge");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const JsonMinimizerPlugin = require("json-minimizer-webpack-plugin");
const BASE_CONFIG = require("./config.base");
function pad(numbers, maxLength, fillString) {
return numbers.map((number) =>
number.toString().padStart(maxLength, fillString)
);
}
/** @type { import('webpack').Configuration } */
const PRODUCTION_CONFIG = {
mode: "production",
module: {
rules: [
{
test: /version\.ts$/,
loader: "string-replace-loader",
options: {
search: /^export const CLIENT_VERSION =.*/,
replace() {
const date = new Date();
const versionPrefix = pad(
[date.getFullYear(), date.getMonth() + 1, date.getDate()],
2,
"0"
).join(".");
const versionSuffix = pad(
[date.getHours(), date.getMinutes()],
2,
"0"
).join(".");
const version = [versionPrefix, versionSuffix].join("_");
return `export const CLIENT_VERSION = "${version}";`;
},
flags: "g",
},
},
{
test: /firebase\.ts$/,
loader: "string-replace-loader",
options: {
search: /\.\/constants\/firebase-config/,
replace() {
return "./constants/firebase-config-live";
},
flags: "g",
},
},
// {
// test: /\.m?js$/,
// exclude: /(node_modules)/,
// use: {
// loader: "babel-loader",
// options: {
// presets: ["@babel/preset-env"],
// plugins: ["@babel/plugin-transform-runtime"],
// },
// },
// },
],
},
optimization: {
minimize: true,
minimizer: [
`...`,
new HtmlMinimizerPlugin(),
new JsonMinimizerPlugin(),
new CssMinimizerPlugin(),
],
},
};
module.exports = merge(BASE_CONFIG, PRODUCTION_CONFIG);