chore: webpack config optimized

This commit is contained in:
Nishchit Dhanani
2023-08-02 16:18:56 +05:30
parent ed165a77e9
commit 63f2febdca
9 changed files with 163 additions and 109 deletions

View File

@@ -85,6 +85,7 @@
"semver": "^7.3.5",
"shelljs": "^0.8.5",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.9",
"ts-loader": "^9.2.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
@@ -95,6 +96,7 @@
"webpack-hot-middleware": "^2.25.1",
"webpack-html-plugin": "^0.1.1",
"webpack-httpolyglot-server": "^0.3.0",
"webpack-merge": "^5.9.0",
"worker-loader": "^3.0.8"
},
"dependencies": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

88
pnpm-lock.yaml generated
View File

@@ -162,6 +162,9 @@ importers:
style-loader:
specifier: ^3.3.1
version: 3.3.1(webpack@5.75.0)
terser-webpack-plugin:
specifier: ^5.3.9
version: 5.3.9(webpack@5.75.0)
ts-loader:
specifier: ^9.2.8
version: 9.4.2(typescript@5.0.2)(webpack@5.75.0)
@@ -192,6 +195,9 @@ importers:
webpack-httpolyglot-server:
specifier: ^0.3.0
version: 0.3.0(webpack@5.75.0)
webpack-merge:
specifier: ^5.9.0
version: 5.9.0
worker-loader:
specifier: ^3.0.8
version: 3.0.8(webpack@5.75.0)
@@ -4503,6 +4509,13 @@ packages:
dependencies:
'@jridgewell/gen-mapping': 0.3.2
'@jridgewell/trace-mapping': 0.3.17
dev: true
/@jridgewell/source-map@0.3.5:
resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==}
dependencies:
'@jridgewell/gen-mapping': 0.3.2
'@jridgewell/trace-mapping': 0.3.17
/@jridgewell/sourcemap-codec@1.4.14:
resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==}
@@ -7483,7 +7496,7 @@ packages:
/@types/testing-library__jest-dom@5.14.5:
resolution: {integrity: sha512-SBwbxYoyPIvxHbeHxTZX2Pe/74F/tX2/D3mMvzabdeJ25bBojfW0TyB8BHrbq/9zaaKICJZjLP+8r6AeZMFCuQ==}
dependencies:
'@types/jest': 29.5.0
'@types/jest': 29.2.4
dev: true
/@types/tough-cookie@4.0.2:
@@ -8651,6 +8664,7 @@ packages:
/async-each@1.0.3:
resolution: {integrity: sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==}
requiresBuild: true
dev: true
optional: true
@@ -9139,6 +9153,7 @@ packages:
/big-integer@1.6.51:
resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==}
engines: {node: '>=0.6'}
requiresBuild: true
dev: true
optional: true
@@ -9153,6 +9168,7 @@ packages:
/binary-extensions@1.13.1:
resolution: {integrity: sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -9253,6 +9269,7 @@ packages:
/bplist-parser@0.1.1:
resolution: {integrity: sha512-2AEM0FXy8ZxVLBuqX0hqt1gDwcnz2zygEkQ6zaD5Wko/sB9paUNwlpawrFtKeHUAQUOzjVy9AO4oeonqIHKA9Q==}
requiresBuild: true
dependencies:
big-integer: 1.6.51
dev: true
@@ -9587,6 +9604,7 @@ packages:
/camelcase-keys@2.1.0:
resolution: {integrity: sha512-bA/Z/DERHKqoEOrp+qeGKw1QlvEQkGZSc0XaY6VnTxZr+Kv1G5zFwttpjv8qxZ/sBPT4nthwZaAcsAZTJlSKXQ==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
camelcase: 2.1.1
map-obj: 1.0.1
@@ -9610,6 +9628,7 @@ packages:
/camelcase@2.1.1:
resolution: {integrity: sha512-DLIsRzJVBQu72meAKPkWQOLcujdXT32hwdfnkI1frSiSRMK1MofjKHf+MEx0SB6fjEFXL8fBDv1dKymBlOp4Qw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -9771,6 +9790,7 @@ packages:
/chokidar@2.1.8:
resolution: {integrity: sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==}
deprecated: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
requiresBuild: true
dependencies:
anymatch: 2.0.0
async-each: 1.0.3
@@ -12809,6 +12829,7 @@ packages:
/find-up@1.1.2:
resolution: {integrity: sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
path-exists: 2.1.0
pinkie-promise: 2.0.1
@@ -13275,6 +13296,7 @@ packages:
/get-stdin@4.0.1:
resolution: {integrity: sha512-F5aQMywwJ2n85s4hJPTT9RPxGmubonuB10MNYo17/xph174n2MIR33HRguhzVag10O/npM7SPk73LMZNP+FaWw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -14316,6 +14338,7 @@ packages:
/indent-string@2.1.0:
resolution: {integrity: sha512-aqwDFWSgSgfRaEwao5lg5KEcVd/2a+D1rvoG7NdilmYz0NwRk6StWpWdz/Hpk34MKPpx7s8XxUqimfcQK6gGlg==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
repeating: 2.0.1
dev: true
@@ -14465,6 +14488,7 @@ packages:
/is-binary-path@1.0.1:
resolution: {integrity: sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
binary-extensions: 1.13.1
dev: true
@@ -14598,6 +14622,7 @@ packages:
/is-finite@1.1.0:
resolution: {integrity: sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -14829,6 +14854,7 @@ packages:
/is-utf8@0.2.1:
resolution: {integrity: sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==}
requiresBuild: true
dev: true
optional: true
@@ -16606,6 +16632,7 @@ packages:
/load-json-file@1.1.0:
resolution: {integrity: sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
graceful-fs: 4.2.11
parse-json: 2.2.0
@@ -17117,6 +17144,7 @@ packages:
/meow@3.7.0:
resolution: {integrity: sha512-TNdwZs0skRlpPpCUK25StC4VH+tP5GgeY1HQOOGP+lQ2xtdkN2VtT/5tiX9k3IWpkBPV9b3LsAWXn4GGi/PrSA==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
camelcase-keys: 2.1.0
decamelize: 1.2.0
@@ -18294,6 +18322,7 @@ packages:
/parse-json@2.2.0:
resolution: {integrity: sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
error-ex: 1.3.2
dev: true
@@ -18378,11 +18407,13 @@ packages:
/path-dirname@1.0.2:
resolution: {integrity: sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==}
requiresBuild: true
dev: true
/path-exists@2.1.0:
resolution: {integrity: sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
pinkie-promise: 2.0.1
dev: true
@@ -18432,6 +18463,7 @@ packages:
/path-type@1.1.0:
resolution: {integrity: sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
graceful-fs: 4.2.11
pify: 2.3.0
@@ -18524,6 +18556,7 @@ packages:
/pinkie-promise@2.0.1:
resolution: {integrity: sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
pinkie: 2.0.4
dev: true
@@ -18537,6 +18570,7 @@ packages:
/pinkie@2.0.4:
resolution: {integrity: sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -19665,6 +19699,7 @@ packages:
/read-pkg-up@1.0.1:
resolution: {integrity: sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
find-up: 1.1.2
read-pkg: 1.1.0
@@ -19691,6 +19726,7 @@ packages:
/read-pkg@1.1.0:
resolution: {integrity: sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
load-json-file: 1.1.0
normalize-package-data: 2.5.0
@@ -19771,6 +19807,7 @@ packages:
/readdirp@2.2.1:
resolution: {integrity: sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==}
engines: {node: '>=0.10'}
requiresBuild: true
dependencies:
graceful-fs: 4.2.11
micromatch: 3.1.10
@@ -19802,6 +19839,7 @@ packages:
/redent@1.0.0:
resolution: {integrity: sha512-qtW5hKzGQZqKoh6JNSD+4lfitfPKGz42e6QwiRmPM5mmKtR0N41AbJRYu0xJi7nhOJ4WDgRkKvAk6tw4WIwR4g==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
indent-string: 2.1.0
strip-indent: 1.0.1
@@ -20013,6 +20051,7 @@ packages:
/repeating@2.0.1:
resolution: {integrity: sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
is-finite: 1.1.0
dev: true
@@ -21286,6 +21325,7 @@ packages:
/strip-bom@2.0.0:
resolution: {integrity: sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
is-utf8: 0.2.1
dev: true
@@ -21319,6 +21359,7 @@ packages:
resolution: {integrity: sha512-I5iQq6aFMM62fBEAIB/hXzwJD6EEZ0xEGCX2t7oXqaKPIRgt4WruAQ285BISgdkP+HLGWyeGmNJcpIwFeRYRUA==}
engines: {node: '>=0.10.0'}
hasBin: true
requiresBuild: true
dependencies:
get-stdin: 4.0.1
dev: true
@@ -21681,6 +21722,30 @@ packages:
serialize-javascript: 6.0.1
terser: 5.16.1
webpack: 5.75.0(webpack-cli@5.0.1)
dev: true
/terser-webpack-plugin@5.3.9(webpack@5.75.0):
resolution: {integrity: sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==}
engines: {node: '>= 10.13.0'}
peerDependencies:
'@swc/core': '*'
esbuild: '*'
uglify-js: '*'
webpack: ^5.1.0
peerDependenciesMeta:
'@swc/core':
optional: true
esbuild:
optional: true
uglify-js:
optional: true
dependencies:
'@jridgewell/trace-mapping': 0.3.17
jest-worker: 27.5.1
schema-utils: 3.1.1
serialize-javascript: 6.0.1
terser: 5.19.2
webpack: 5.75.0(webpack-cli@5.0.1)
/terser@4.8.1:
resolution: {integrity: sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw==}
@@ -21702,6 +21767,17 @@ packages:
acorn: 8.8.2
commander: 2.20.3
source-map-support: 0.5.21
dev: true
/terser@5.19.2:
resolution: {integrity: sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==}
engines: {node: '>=10'}
hasBin: true
dependencies:
'@jridgewell/source-map': 0.3.5
acorn: 8.8.2
commander: 2.20.3
source-map-support: 0.5.21
/test-exclude@6.0.0:
resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==}
@@ -21886,6 +21962,7 @@ packages:
/trim-newlines@1.0.0:
resolution: {integrity: sha512-Nm4cF79FhSTzrLKGDMi3I4utBtFv8qKy4sq1enftf2gMdpqI8oVQTAfySkTz5r49giVzDj88SVZXP4CeYQwjaw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: true
optional: true
@@ -22582,6 +22659,7 @@ packages:
/untildify@2.1.0:
resolution: {integrity: sha512-sJjbDp2GodvkB0FZZcn7k6afVisqX5BZD7Yq3xp4nN2O15BBK0cLm3Vwn2vQaF7UDS0UUsrQMkkplmDI5fskig==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dependencies:
os-homedir: 1.0.2
dev: true
@@ -23030,7 +23108,7 @@ packages:
webpack: 5.75.0(webpack-cli@5.0.1)
webpack-bundle-analyzer: 4.7.0
webpack-dev-server: 4.11.1(webpack-cli@5.0.1)(webpack@5.75.0)
webpack-merge: 5.8.0
webpack-merge: 5.9.0
/webpack-dev-middleware@2.0.6(webpack@5.75.0):
resolution: {integrity: sha512-tj5LLD9r4tDuRIDa5Mu9lnY2qBBehAITv6A9irqXhw/HQquZgTx3BCd57zYbU2gMDnncA49ufK2qVQSbaKJwOw==}
@@ -23197,8 +23275,8 @@ packages:
uuid: 3.4.0
dev: true
/webpack-merge@5.8.0:
resolution: {integrity: sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==}
/webpack-merge@5.9.0:
resolution: {integrity: sha512-6NbRQw4+Sy50vYNTw7EyOn41OZItPiXB8GNv3INSoe3PSFaHJEz3SHTrYVaRm2LilNGnFUzh0FAwqPEmU/CwDg==}
engines: {node: '>=10.0.0'}
dependencies:
clone-deep: 4.0.1
@@ -23299,7 +23377,7 @@ packages:
neo-async: 2.6.2
schema-utils: 3.1.1
tapable: 2.2.1
terser-webpack-plugin: 5.3.6(webpack@5.75.0)
terser-webpack-plugin: 5.3.9(webpack@5.75.0)
watchpack: 2.4.0
webpack-cli: 5.0.1(webpack-bundle-analyzer@4.7.0)(webpack-dev-server@4.11.1)(webpack@5.75.0)
webpack-sources: 3.2.3

View File

@@ -3,10 +3,11 @@ require('dotenv').config();
const fs = require('fs');
const path = require('path');
require('shelljs/global');
const { Environment, AppFormat } = require('./constants');
const build = require('../webpack.prod');
const { Environment } = require('./constants');
const env = process.env.NODE_ENV;
const build =
env === 'production' ? require('../webpack.prod') : require('../webpack.dev');
module.exports = async () => {
try {

View File

@@ -36,10 +36,8 @@ if (
process.exit();
}
const preBuildCliCommands = async () => {
// pre conditions can be validated here
return Promise.resolve();
};
const preBuildCliCommands = async () => Promise.resolve();
if ([Environment.Production, Environment.Staging].includes(env)) {
try {

View File

@@ -2,6 +2,8 @@
require('dotenv').config();
/* eslint-disable no-console */
require('dotenv-vault-core').config();
const TerserPlugin = require('terser-webpack-plugin');
console.log(process.env.FIRECAMP_API_HOST, 'FIRECAMP_API_HOST'); // for debugging purposes. remove when ready.
const webpack = require('webpack');
@@ -10,13 +12,12 @@ const path = require('path');
// const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { Environment } = require('./scripts/constants');
const env = process.env.NODE_ENV;
const metadata = require('./package.json');
exports.common = {
const common = {
entry: {
index: path.join(
__dirname,
@@ -30,6 +31,11 @@ exports.common = {
optimization: {
nodeEnv: process.env.NODE_ENV,
minimize: true,
minimizer: [
new TerserPlugin({
parallel: 2,
}),
],
runtimeChunk: 'single',
splitChunks: {
// name: 'vendor',
@@ -82,7 +88,7 @@ exports.common = {
const outputPath = `${__dirname}/build/${env}`;
const publicPath = '';
exports.output = {
const output = {
globalObject: 'this',
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
@@ -91,9 +97,8 @@ exports.output = {
};
// exports.output.path = path.join(__dirname, `./build/${env}`);
if (env === Environment.Development) exports.output.clean = true;
exports.env = {
const _env = {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
FIRECAMP_API_HOST: JSON.stringify(process.env.FIRECAMP_API_HOST),
FIRECAMP_CLOUD_AGENT: JSON.stringify(process.env.FIRECAMP_CLOUD_AGENT),
@@ -121,7 +126,7 @@ exports.env = {
),
};
exports.plugins = [
const plugins = [
new HtmlWebpackPlugin({
inject: true,
chunks: ['index'],
@@ -156,10 +161,46 @@ exports.plugins = [
// publicPath: '/js',
// filename: '[name].worker.bundle.js',
// languages: ['javascript', 'html', 'typescript', 'json'],
// }),
// }),11
new webpack.DefinePlugin({
'process.env': {
..._env,
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(
process.env.FIRECAMP_EXTENSION_AGENT_ID
),
},
}),
];
exports.rules = [
const rules = [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: [
'@babel/preset-env',
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
['@babel/plugin-proposal-export-default-from'],
'add-module-exports',
],
},
},
{ test: /\.flow$/, loader: 'ignore-loader' },
{
test: /\.css$/,
@@ -195,3 +236,12 @@ exports.rules = [
},
},
];
module.exports = {
...common,
mode: 'development',
devtool: 'eval-cheap-module-source-map',
output,
plugins,
module: { rules },
};

View File

@@ -1,18 +1,18 @@
// imports environment
require('dotenv').config();
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { common, env, plugins, rules, output } = require('./webpack.config');
const base = require('./webpack.common');
const withReport = process.env.npm_config_withReport;
module.exports = {
...common,
module.exports = merge(base, {
mode: 'development',
devtool: 'eval-cheap-module-source-map',
devtool: 'cheap-module-source-map',
output: { clean: true },
devServer: {
//server: 'https',
static: path.join(__dirname, './build/development'),
@@ -28,51 +28,9 @@ module.exports = {
'X-Requested-With, content-type, Authorization',
},
},
output,
plugins: [
...plugins,
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin({ resourceRegExp: /[^/]+\/[\S]+.dev$/ }),
new webpack.DefinePlugin({
'process.env': {
...env,
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(
process.env.FIRECAMP_EXTENSION_AGENT_ID
),
},
}),
// new BundleAnalyzerPlugin(),
],
module: {
rules: [
...rules,
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
['@babel/plugin-proposal-export-default-from'],
'add-module-exports',
],
},
},
],
},
};
});

View File

@@ -1,12 +1,13 @@
/* eslint-disable no-console */
const path = require('path');
const webpack = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const { common, env, plugins, rules } = require('./webpack.config');
const { merge } = require('webpack-merge');
// const CompressionPlugin = require('compression-webpack-plugin');
const base = require('./webpack.common');
const nodeEnv = process.env.NODE_ENV;
const config = {
...common,
const config = merge(base, {
mode: 'production',
output: {
globalObject: 'this',
@@ -15,7 +16,6 @@ const config = {
path: path.join(__dirname, `./build/${nodeEnv}`),
},
plugins: [
...plugins,
new webpack.ProvidePlugin({
React: 'react',
}),
@@ -24,41 +24,8 @@ const config = {
'process.env': env,
}),
new CompressionPlugin(),
],
module: {
rules: [
...rules,
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
['@babel/plugin-proposal-export-default-from'],
'add-module-exports',
['transform-remove-console', { exclude: ['info'] }],
],
},
},
],
},
};
]
});
module.exports = () =>
new Promise((resolve, reject) => {