Преглед на файлове

fix(build) reduce bundle size by about 700K

app.bundle.js before: 3851549 after: 4506493.

The culprit for the bloat was Olm. It feature-detects the environment in order
to pick a suitable random byte generator, and alas Webpack includes the None
crypto pollyfill. This is due to the existence of the "node" block in our
Webpack configuration file.

The solution is to provide empty modules to make bundling work, as we did
already for the fs module, since we know they are not used at runtime.
master
Saúl Ibarra Corretgé преди 4 години
родител
ревизия
69b7301b9d
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3
    2
      webpack.config.js

+ 3
- 2
webpack.config.js Целия файл

@@ -142,7 +142,8 @@ const config = {
142 142
         // value that is a mock (/index.js).
143 143
         __filename: true,
144 144
 
145
-        // Provide an empty 'fs' module.
145
+        // Provide some empty Node modules (required by olm).
146
+        crypto: 'empty',
146 147
         fs: 'empty'
147 148
     },
148 149
     optimization: {
@@ -190,7 +191,7 @@ module.exports = [
190 191
         entry: {
191 192
             'app.bundle': './app.js'
192 193
         },
193
-        performance: getPerformanceHints(4.5 * 1024 * 1024)
194
+        performance: getPerformanceHints(4 * 1024 * 1024)
194 195
     }),
195 196
     Object.assign({}, config, {
196 197
         entry: {

Loading…
Отказ
Запис