From 698d47e2219833af5dd9e6976b66e17c86d40498 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 11 Apr 2022 16:25:28 +0530 Subject: [PATCH] Enable plugins in config --- vite.common-config.js | 21 +++++++++++++++------ vite.config.js | 4 +++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/vite.common-config.js b/vite.common-config.js index 44c884bd..f5a90154 100644 --- a/vite.common-config.js +++ b/vite.common-config.js @@ -1,9 +1,15 @@ const cssvariables = require("postcss-css-variables"); const flexbugsFixes = require("postcss-flexbugs-fixes"); +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"); const manifest = require("./package.json"); const version = manifest.version; +const compiledVariables = new Map(); +const derive = require("./scripts/postcss/color").derive; +const replacer = require("./scripts/postcss/svg-colorizer").buildColorizedSVG; const commonOptions = { logLevel: "warn", @@ -32,11 +38,14 @@ const commonOptions = { css: { postcss: { plugins: [ - cssvariables({ - preserve: (declaration) => { - return declaration.value.indexOf("var(--ios-") == 0; - } - }), + compileVariables({derive, compiledVariables}), + urlVariables({compileVariables}), + 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"}), @@ -46,4 +55,4 @@ const commonOptions = { } }; -module.exports = commonOptions; +module.exports = { commonOptions, compiledVariables }; diff --git a/vite.config.js b/vite.config.js index b6ec597d..8cc16d26 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,8 +1,9 @@ const injectWebManifest = require("./scripts/build-plugins/manifest"); const {injectServiceWorker, createPlaceholderValues} = require("./scripts/build-plugins/service-worker"); +const themeBuilder = require("./scripts/build-plugins/rollup-plugin-build-themes"); const {defineConfig} = require('vite'); const mergeOptions = require('merge-options').bind({concatArrays: true}); -const commonOptions = require("./vite.common-config.js"); +const {commonOptions, compiledVariables} = require("./vite.common-config.js"); export default defineConfig(({mode}) => { const definePlaceholders = createPlaceholderValues(mode); @@ -15,6 +16,7 @@ export default defineConfig(({mode}) => { sourcemap: true, }, plugins: [ + themeBuilder({manifestLocations: ["./src/platform/web/ui/css/themes/element"], compiledVariables}), // important this comes before service worker // otherwise the manifest and the icons it refers to won't be cached injectWebManifest("assets/manifest.json"),