Exclude olm from the webpack
Olm takes *ages* to webpack, and it doesn't compress well. So, serve it as a separate asset to the browser.
This commit is contained in:
parent
2829d95705
commit
51b74251f9
4 changed files with 39 additions and 24 deletions
|
@ -43,12 +43,16 @@ module.exports = {
|
|||
|
||||
// same goes for js-sdk
|
||||
"matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),
|
||||
|
||||
// make sure we use the version of olm from vector-web rather than
|
||||
// js-sdk.
|
||||
"olm": path.resolve('./node_modules/olm'),
|
||||
},
|
||||
},
|
||||
externals: {
|
||||
// olm takes ages for webpack to process, and it's already heavily
|
||||
// optimised, so there is little to gain by us uglifying it. We
|
||||
// therefore use it via a separate <script/> tag in index.html (which
|
||||
// loads it into the browser global `Olm`), and reference it as an
|
||||
// external here.
|
||||
"olm": "Olm",
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
|
@ -59,20 +63,6 @@ module.exports = {
|
|||
new ExtractTextPlugin("bundle.css", {
|
||||
allChunks: true
|
||||
}),
|
||||
|
||||
// olm.js includes "require 'fs'", which is never
|
||||
// executed in the browser. Ignore it.
|
||||
new webpack.IgnorePlugin(/^fs$/, /\/olm$/)
|
||||
],
|
||||
devtool: 'source-map'
|
||||
};
|
||||
|
||||
// ignore olm.js if it's not installed, to avoid a scary-looking error.
|
||||
try {
|
||||
require('olm');
|
||||
console.log("Olm is installed; including it in webpack bundle");
|
||||
} catch (e) {
|
||||
module.exports.plugins.push(
|
||||
new webpack.IgnorePlugin(/^olm$/)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue