Просмотр исходного кода

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.
j8
Saúl Ibarra Corretgé 4 лет назад
Родитель
Сommit
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: {

Загрузка…
Отмена
Сохранить