monkeytype/frontend/webpack/config.prod.js
Bruce Berrios 032fe57f2a
Consolidate webpack configurations (#2716) bruception
* Consolidate webpack configurations

* Add lint step back into dev compilation
2022-03-16 20:57:30 +01:00

46 lines
1.2 KiB
JavaScript

const { merge } = require("webpack-merge");
const BASE_CONFIGURATION = require("./config.base");
const PRODUCTION_CONFIGURATION = {
mode: "production",
module: {
rules: [
{
test: /version\.ts$/,
loader: "string-replace-loader",
options: {
search: /^export const CLIENT_VERSION =.*/,
replace(_match, _p1, _offset, _string) {
const date = new Date();
const dateString = [
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
].join("-");
return `export const CLIENT_VERSION = "${dateString}";`;
},
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",
],
},
},
},
],
},
};
module.exports = merge(BASE_CONFIGURATION, PRODUCTION_CONFIGURATION);