瀏覽代碼

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 年之前
父節點
當前提交
69b7301b9d
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3
    2
      webpack.config.js

+ 3
- 2
webpack.config.js 查看文件

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

Loading…
取消
儲存