forked from matrix/element-web
webpack: Use `require` to look for olm
Since https://github.com/matrix-org/matrix-js-sdk/pull/141, the jenkins build does pull in the olm module, but because it's using npm v2, buries it deep in node_modules. Rather than using the `fs` module to hunt for it, just try to `require` it in the webpack config.
This commit is contained in:
parent
654429dbdb
commit
664f809362
|
@ -2,8 +2,6 @@ var path = require('path');
|
|||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
|
||||
var olm_path = path.resolve('./node_modules/olm');
|
||||
|
||||
module.exports = {
|
||||
module: {
|
||||
preLoaders: [
|
||||
|
@ -45,11 +43,6 @@ module.exports = {
|
|||
|
||||
// same goes for js-sdk
|
||||
"matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),
|
||||
|
||||
// matrix-js-sdk will use olm if it is available,
|
||||
// but does not explicitly depend on it. Pull it
|
||||
// in from node_modules if it's there.
|
||||
olm: olm_path,
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
|
@ -65,20 +58,17 @@ module.exports = {
|
|||
|
||||
// olm.js includes "require 'fs'", which is never
|
||||
// executed in the browser. Ignore it.
|
||||
new webpack.IgnorePlugin(/^fs$/, /node_modules\/olm$/)
|
||||
new webpack.IgnorePlugin(/^fs$/, /\/olm$/)
|
||||
],
|
||||
devtool: 'source-map'
|
||||
};
|
||||
|
||||
// ignore olm.js if it's not installed.
|
||||
(function() {
|
||||
var fs = require('fs');
|
||||
// ignore olm.js if it's not installed, to avoid a scary-looking error.
|
||||
try {
|
||||
fs.lstatSync(olm_path);
|
||||
require('olm');
|
||||
console.log("Olm is installed; including it in webpack bundle");
|
||||
} catch (e) {
|
||||
module.exports.plugins.push(
|
||||
new webpack.IgnorePlugin(/^olm$/)
|
||||
);
|
||||
}
|
||||
}) ();
|
||||
|
|
Loading…
Reference in New Issue