monkeytype/frontend/webpack/config.prod.js
Jack fe668e4811
Moved firebase to new modular version 9 sdk (#2727)
* using modular sdk

* removing last script

* replacing more code

* unused code

* removed unused code

* removed unused code

* importing auth

* using analytics controller

* importing auth and analytics

* importing auth

* updated git ignore

* fixed path

* removed live config from gitignore

* added error message when failing to initialize firebase

* added live config
using live config when building production

* removed unused code

* fixed incorrect function use

* added example config

* added a step to the contributing guide

* optional steps

* fixed path

* using example in source code so that github actions dont cry like little babies

* using function correctly

* using function correctly

* ignoring live

* removed

* added action webpack config

* bruce said "no-no"

This reverts commit 0a1e5e1660.

* Fix

* Add ignore

* updated instructions

* using correct functions

* using correct function

* missing parameter

* using correct function

* using correct function

* removed ts ignores

* using new functions

* removed refresh

* using new functions

* merge fix

* fixed merge

* regenereated lockfile

* using correct function

* defaulting to the email thats already entered

* moved lines

Co-authored-by: Bruception <bberr022@fiu.edu>
2022-03-19 12:33:25 +01:00

82 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_CONFIGURATION = require("./config.base");
function pad(numbers, maxLength, fillString) {
return numbers.map((number) =>
number.toString().padStart(maxLength, fillString)
);
}
const PRODUCTION_CONFIGURATION = {
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",
"@babel/plugin-transform-modules-commonjs",
],
},
},
},
],
},
optimization: {
minimize: true,
minimizer: [
`...`,
new HtmlMinimizerPlugin(),
new JsonMinimizerPlugin(),
new CssMinimizerPlugin(),
],
},
};
module.exports = merge(BASE_CONFIGURATION, PRODUCTION_CONFIGURATION);