mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
3bee4b4585
bs58 depends on safe-buffer, which depends on buffer, which is a bit of a pain to bundle as it is a built-in node module. You'd typically replace buffer with a browser polyfill in your build system but: a) this is somewhat a pain to setup for simple apps b) the polyfill is way more than we need (6kb), so we prefer to bundle our minimal buffer replacement that uses Uint8Array. Since it is a transitive dependency, we need to bundle bs58 and all of its transitive dependencies (2.5kb) as well, so if users of hydrogen-sdk also use any of these, they'll be double included in their bundle.
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
const cssvariables = require("postcss-css-variables");
|
|
const flexbugsFixes = require("postcss-flexbugs-fixes");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const manifest = require("./package.json");
|
|
const version = manifest.version;
|
|
|
|
const commonOptions = {
|
|
logLevel: "info",
|
|
publicDir: false,
|
|
server: {
|
|
hmr: false
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
// these should only be imported by the base-x package in any runtime code
|
|
// and works in the browser with a Uint8Array shim,
|
|
// rather than including a ton of polyfill code
|
|
"safe-buffer": "./scripts/package-overrides/safe-buffer/index.js",
|
|
"buffer": "./scripts/package-overrides/buffer/index.js",
|
|
}
|
|
},
|
|
build: {
|
|
emptyOutDir: true,
|
|
assetsInlineLimit: 0,
|
|
polyfillModulePreload: false,
|
|
},
|
|
define: {
|
|
DEFINE_VERSION: JSON.stringify(version),
|
|
DEFINE_GLOBAL_HASH: JSON.stringify(null),
|
|
},
|
|
css: {
|
|
postcss: {
|
|
plugins: [
|
|
cssvariables({
|
|
preserve: (declaration) => {
|
|
return declaration.value.indexOf("var(--ios-") == 0;
|
|
}
|
|
}),
|
|
// the grid option creates some source fragment that causes the vite warning reporter to crash because
|
|
// it wants to log a warning on a line that does not exist in the source fragment.
|
|
// autoprefixer({overrideBrowserslist: ["IE 11"], grid: "no-autoplace"}),
|
|
flexbugsFixes()
|
|
]
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = commonOptions;
|