mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 11:36:24 +01:00
ceb0b5793b
it's missing still: - non-css assets like the download sandbox and the olm worker aren't written for some reason - the es and cjs lib.js entry points end up in assets with a hash for some reason - in these entry files, apart from our exports, something is adding an import statement for every import that was found in the tree - all assets are hashed even though the config tries to disable that - tests are included
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
const injectWebManifest = require("./scripts/build-plugins/manifest");
|
|
const {injectServiceWorker, createPlaceholderValues} = require("./scripts/build-plugins/service-worker");
|
|
const {defineConfig} = require('vite');
|
|
const mergeOptions = require('merge-options').bind({concatArrays: true});
|
|
const commonOptions = require("./vite.common-config.js");
|
|
|
|
export default defineConfig(({mode}) => {
|
|
const definePlaceholders = createPlaceholderValues(mode);
|
|
return mergeOptions(commonOptions, {
|
|
root: "src/platform/web",
|
|
base: "./",
|
|
build: {
|
|
outDir: "../../../target",
|
|
minify: true,
|
|
sourcemap: true,
|
|
},
|
|
plugins: [
|
|
// important this comes before service worker
|
|
// otherwise the manifest and the icons it refers to won't be cached
|
|
injectWebManifest("assets/manifest.json"),
|
|
injectServiceWorker("./src/platform/web/sw.js", ["index.html"], {
|
|
// placeholders to replace at end of build by chunk name
|
|
"index": {DEFINE_GLOBAL_HASH: definePlaceholders.DEFINE_GLOBAL_HASH},
|
|
"sw": definePlaceholders
|
|
}),
|
|
],
|
|
define: definePlaceholders,
|
|
});
|
|
});
|