From 2bd4f0a601c7074999cef2490f5968c7ffcb001c Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Mon, 30 Aug 2021 02:26:38 +0300 Subject: [PATCH] Refactor minifyStyles plugin - migrated to visitor plugin api - covered with types - get rid from "traverse" usage Splitted the work to collecting and modifying when root exit. --- plugins/minifyStyles.js | 269 ++++++++++++++++++++-------------------- tsconfig.json | 1 - 2 files changed, 132 insertions(+), 138 deletions(-) diff --git a/plugins/minifyStyles.js b/plugins/minifyStyles.js index 36ea08944..c6cb13a60 100644 --- a/plugins/minifyStyles.js +++ b/plugins/minifyStyles.js @@ -1,153 +1,148 @@ 'use strict'; +/** + * @typedef {import('../lib/types').XastElement} XastElement + */ + const csso = require('csso'); -const { traverse } = require('../lib/xast.js'); +exports.type = 'visitor'; exports.name = 'minifyStyles'; - -exports.type = 'full'; - exports.active = true; - exports.description = 'minifies styles and removes unused styles based on usage data'; -exports.params = { - // ... CSSO options goes here - - // additional - usage: { - force: false, // force to use usage data even if it unsafe (document contains