From ca49d60c1d29cf2673a35dc7bed290e0c5d2cdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= <20689156+shortcuts@users.noreply.github.com> Date: Fri, 23 Jul 2021 18:30:18 +0200 Subject: [PATCH] feat(theme): provide non-minified theme (#635) --- bundlesize.config.json | 2 +- .../autocomplete-theme-classic/package.json | 10 ++++--- postcss.config.mjs | 26 ++++++++++--------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/bundlesize.config.json b/bundlesize.config.json index 53ce2252c..a4a3a54cb 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -25,7 +25,7 @@ "maxSize": "4 kB" }, { - "path": "packages/autocomplete-theme-classic/dist/theme.css", + "path": "packages/autocomplete-theme-classic/dist/theme.min.css", "maxSize": "4.25 kB" } ] diff --git a/packages/autocomplete-theme-classic/package.json b/packages/autocomplete-theme-classic/package.json index f4278a0df..f8d10b5ab 100644 --- a/packages/autocomplete-theme-classic/package.json +++ b/packages/autocomplete-theme-classic/package.json @@ -15,12 +15,14 @@ "files": [ "dist/" ], - "main": "dist/theme.css", - "unpkg": "dist/theme.css", - "jsdelivr": "dist/theme.css", + "main": "dist/theme.min.css", + "unpkg": "dist/theme.min.css", + "jsdelivr": "dist/theme.min.css", "scripts": { "build:clean": "rm -rf ./dist", - "build:css": "node ../../scripts/buildCss.mjs src/theme.scss dist/theme.css", + "build:css": "yarn build:css:minified && yarn build:css:unminified", + "build:css:minified": "MINIFIED=TRUE node ../../scripts/buildCss.mjs src/theme.scss dist/theme.min.css", + "build:css:unminified": "node ../../scripts/buildCss.mjs src/theme.scss dist/theme.css", "build": "yarn build:clean && yarn build:css", "on:change": "yarn build:css", "prepare": "yarn build:css", diff --git a/postcss.config.mjs b/postcss.config.mjs index 7d49031c0..89a0deb06 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -1,21 +1,23 @@ +import sass from '@csstools/postcss-sass'; import autoprefixer from 'autoprefixer'; import cssnano from 'cssnano'; import color from 'postcss-color-rgb'; import comment from 'postcss-comment'; -import sass from '@csstools/postcss-sass'; import presetEnv from 'postcss-preset-env'; +const MINIFIED = process.env.MINIFIED; +const plugins = [ + presetEnv({ + features: { + 'nesting-rules': false, + }, + }), + color, + sass, + autoprefixer, +]; + export default { parser: comment, - plugins: [ - presetEnv({ - features: { - 'nesting-rules': false, - }, - }), - color, - sass, - autoprefixer, - cssnano, - ], + plugins: MINIFIED ? [...plugins, cssnano] : plugins, };