2021-12-01 18:10:25 +01:00
|
|
|
const injectWebManifest = require("./scripts/build-plugins/manifest");
|
2021-12-09 16:37:31 +01:00
|
|
|
const {injectServiceWorker, createPlaceholderValues} = require("./scripts/build-plugins/service-worker");
|
|
|
|
const {defineConfig} = require('vite');
|
2021-12-10 16:03:17 +01:00
|
|
|
const mergeOptions = require('merge-options').bind({concatArrays: true});
|
|
|
|
const commonOptions = require("./vite.common-config.js");
|
2021-10-06 20:34:16 +02:00
|
|
|
|
2021-12-09 16:37:31 +01:00
|
|
|
export default defineConfig(({mode}) => {
|
|
|
|
const definePlaceholders = createPlaceholderValues(mode);
|
2021-12-10 16:03:17 +01:00
|
|
|
return mergeOptions(commonOptions, {
|
2021-12-09 16:37:31 +01:00
|
|
|
root: "src/platform/web",
|
|
|
|
base: "./",
|
|
|
|
build: {
|
|
|
|
outDir: "../../../target",
|
2021-12-17 14:28:25 +01:00
|
|
|
minify: true,
|
|
|
|
sourcemap: true,
|
2021-12-09 16:37:31 +01:00
|
|
|
},
|
|
|
|
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
|
|
|
|
}),
|
|
|
|
],
|
2021-12-10 16:03:17 +01:00
|
|
|
define: definePlaceholders,
|
|
|
|
});
|
2021-12-09 16:37:31 +01:00
|
|
|
});
|