From 284b130d02b21c5368bbdd836130fb6936e3e1b0 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Mon, 16 Jan 2023 13:32:28 +0300 Subject: [PATCH] feat(element): add standalone styles --- scripts/build-element.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/build-element.js b/scripts/build-element.js index 95bfb1ea4..461c737dc 100644 --- a/scripts/build-element.js +++ b/scripts/build-element.js @@ -90,6 +90,9 @@ export default async function buildElement() { cssStylesBundle = proceedReplacements(cssStylesBundle); cssStylesCore = proceedReplacements(cssStylesCore); + const cssStylesBundleStandalone = cssStylesBundle; + const cssStylesCoreStandalone = cssStylesCore; + const fontStyles = await cleanCss(cssStylesCore.split('/* FONT_END */')[0]); cssStylesBundle = await cleanCss(cssStylesBundle.split('/* FONT_END */')[1]); cssStylesCore = await cleanCss(cssStylesCore.split('/* FONT_END */')[1]); @@ -119,6 +122,18 @@ export default async function buildElement() { }), ); + // standalone styles + fs.writeFileSync(path.resolve(outputDir, 'swiper-element.css'), cssStylesCoreStandalone); + fs.writeFileSync( + path.resolve(outputDir, 'swiper-element.min.css'), + await cleanCss(cssStylesCoreStandalone), + ); + fs.writeFileSync(path.resolve(outputDir, 'swiper-element-bundle.css'), cssStylesBundleStandalone); + fs.writeFileSync( + path.resolve(outputDir, 'swiper-element-bundle.min.css'), + await cleanCss(cssStylesBundleStandalone), + ); + // ESM fs.copyFileSync('./src/element/get-params.js', path.resolve(outputDir, 'element/get-params.js')); const elementContent = fs.readFileSync('./src/element/swiper-element.js', 'utf-8');