vector-im-hydrogen-web/vite.common-config.js

60 lines
2.2 KiB
JavaScript
Raw Normal View History

const cssvariables = require("postcss-css-variables");
const flexbugsFixes = require("postcss-flexbugs-fixes");
2022-04-11 12:55:28 +02:00
const compileVariables = require("./scripts/postcss/css-compile-variables");
const urlVariables = require("./scripts/postcss/css-url-to-variables");
const urlProcessor = require("./scripts/postcss/css-url-processor");
const fs = require("fs");
const path = require("path");
2021-12-17 16:13:26 +01:00
const manifest = require("./package.json");
const version = manifest.version;
2022-04-11 12:55:28 +02:00
const compiledVariables = new Map();
2022-07-15 11:27:00 +02:00
import {buildColorizedSVG as replacer} from "./scripts/postcss/svg-builder.mjs";
2022-07-19 11:41:05 +02:00
import {derive} from "./src/platform/web/theming/shared/color.mjs";
const commonOptions = {
2021-12-22 16:25:09 +01:00
logLevel: "warn",
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,
},
2022-04-20 08:55:23 +02:00
assetsInclude: ['**/config.json'],
define: {
DEFINE_VERSION: JSON.stringify(version),
DEFINE_GLOBAL_HASH: JSON.stringify(null),
},
css: {
postcss: {
plugins: [
2022-04-11 12:55:28 +02:00
compileVariables({derive, compiledVariables}),
urlVariables({compiledVariables}),
2022-04-11 12:55:28 +02:00
urlProcessor({replacer}),
// 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()
]
}
}
};
2022-04-11 12:55:28 +02:00
module.exports = { commonOptions, compiledVariables };