UNPKG

@wonderflow/config

Version:

Wanda design system shared configurations

70 lines (69 loc) 2.35 kB
"use strict"; /* * Copyright 2022-2023 Wonderflow Design Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.postcssConfig = void 0; var tokens_json_1 = __importDefault(require("@wonderflow/tokens/platforms/web/tokens.json")); var flat_1 = __importDefault(require("flat")); var postcss_mixins_1 = __importDefault(require("postcss-mixins")); /** * Prepare env variables from tokens * to be assigned to postcss-preset-env */ var flatTokens = (0, flat_1.default)(tokens_json_1.default, { delimiter: '-', }); var prepareTokens = function () { return Object.keys(flatTokens).reduce(function (acc, key) { var newKey = key; acc[newKey] = "".concat(flatTokens[key]); return acc; }, {}); }; exports.postcssConfig = { plugins: { 'postcss-import': {}, 'postcss-replace': { pattern: /token\(.*?--([^\s]+?)\)/gi, data: prepareTokens(), }, 'postcss-preset-env': { stage: 0, features: { 'logical-properties-and-values': false, 'prefers-color-scheme-query': false, 'gap-properties': false, 'cascade-layers': false, }, insertAfter: { 'custom-media-queries': postcss_mixins_1.default, }, enableClientSidePolyfills: false, }, 'postcss-mixins': {}, cssnano: { preset: [ 'default', { discardComments: { removeAll: true, }, }, ], }, }, };