Skip to content

Commit

Permalink
Reduce compressed bundle size from 2.72 MB to 2.64 MB with some webpa…
Browse files Browse the repository at this point in the history
…ck tricks (#1392)

* Reduce compressed bundle size from 2.72 MB to 2.64 MB with some webpack tricks

* minor
  • Loading branch information
AlexNisnevich authored Jan 4, 2021
1 parent f60fb91 commit 17f1fb6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"@typescript-eslint/parser": "^4.9.0",
"awesome-typescript-loader": "^5.0.0",
"babel-loader": "^8.0.1",
"babel-plugin-lodash": "^3.3.4",
"copy-webpack-plugin": "^4.5.0",
"css-loader": "^1.0.0",
"csstype": "^2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/game/Sfx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { inBrowser, isFlagSet } from '../../util/browser';

const Sound = inBrowser() ? require('react-sound').default : null;
const soundManager = inBrowser() ? require('soundmanager2').soundManager : null;
const soundManager = inBrowser() ? require('soundmanager2/script/soundmanager2-nodebug').soundManager : null;

interface SfxProps {
queue: string[]
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const webpackConfig = {
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['react-hot-loader/babel', '@babel/plugin-syntax-dynamic-import']
plugins: ['react-hot-loader/babel', '@babel/plugin-syntax-dynamic-import', 'babel-plugin-lodash']
}
},
{
Expand Down Expand Up @@ -56,10 +56,10 @@ const webpackConfig = {
},
plugins: compact([
!isProduction && new webpack.HotModuleReplacementPlugin(),
new webpack.EnvironmentPlugin({ NODE_ENV: 'development', PARSER: null, FIREBASE_DB: null }),
new CopyWebpackPlugin([{from: 'static'}]),
new webpack.IgnorePlugin(/^canvas$/),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // Ignore all locale files of moment.js
new webpack.EnvironmentPlugin({ NODE_ENV: 'development', PARSER: null, FIREBASE_DB: null })
]),
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
Expand Down
33 changes: 32 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@
dependencies:
"@babel/types" "^7.12.7"

"@babel/helper-module-imports@^7.12.1":
"@babel/helper-module-imports@^7.0.0-beta.49", "@babel/helper-module-imports@^7.12.1":
version "7.12.5"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb"
integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA==
dependencies:
"@babel/types" "^7.12.5"

Expand Down Expand Up @@ -177,6 +178,11 @@
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2"

"@babel/helper-validator-identifier@^7.12.11":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed"
integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==

"@babel/helpers@^7.12.5":
version "7.12.5"
resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.12.5.tgz#1a1ba4a768d9b58310eda516c449913fe647116e"
Expand Down Expand Up @@ -373,6 +379,15 @@
lodash "^4.17.10"
to-fast-properties "^2.0.0"

"@babel/types@^7.0.0-beta.49":
version "7.12.12"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.12.tgz#4608a6ec313abbd87afa55004d373ad04a96c299"
integrity sha512-lnIX7piTxOH22xE7fDXDbSHg9MM1/6ORnafpJmov5rs0kX5g4BZxeXNJLXsMRiO0U5Rb8/FvMS6xlTnTHvxonQ==
dependencies:
"@babel/helper-validator-identifier" "^7.12.11"
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.3":
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13"
Expand Down Expand Up @@ -2104,6 +2119,17 @@ babel-plugin-jest-hoist@^26.6.2:
"@types/babel__core" "^7.0.0"
"@types/babel__traverse" "^7.0.6"

babel-plugin-lodash@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.3.4.tgz#4f6844358a1340baed182adbeffa8df9967bc196"
integrity sha512-yDZLjK7TCkWl1gpBeBGmuaDIFhZKmkoL+Cu2MUUjv5VxUZx/z7tBGBCBcQs5RI1Bkz5LLmNdjx7paOyQtMovyg==
dependencies:
"@babel/helper-module-imports" "^7.0.0-beta.49"
"@babel/types" "^7.0.0-beta.49"
glob "^7.1.1"
lodash "^4.17.10"
require-package-name "^2.0.1"

babel-preset-current-node-syntax@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.0.tgz#cf5feef29551253471cfa82fc8e0f5063df07a77"
Expand Down Expand Up @@ -9527,6 +9553,11 @@ require-main-filename@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"

require-package-name@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9"
integrity sha1-wR6XJ2tluOKSP3Xav1+y7ww4Qbk=

[email protected], requires-port@^1.0.0, requires-port@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand Down

0 comments on commit 17f1fb6

Please sign in to comment.