Skip to content

Commit

Permalink
refactor: transformer order
Browse files Browse the repository at this point in the history
css.purge should run after posthtml-mso, so that it can actually remove outlook comments
  • Loading branch information
cossssmin committed Sep 28, 2024
1 parent c735364 commit 4a24a9b
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,7 @@ export async function run(html = '', config = {}) {
}

/**
* 8. Purge CSS
*
* Remove unused CSS, uglify classes etc.
*/
if (get(config, 'css.purge')) {
posthtmlPlugins.push(comb(config.css.purge))
}

/**
* 9. Remove attributes
* 8. Remove attributes
*
* Remove attributes from HTML tags
* If `undefined`, removes empty `style` and `class` attributes
Expand All @@ -148,7 +139,7 @@ export async function run(html = '', config = {}) {
}

/**
* 10. Shorthand CSS
* 9. Shorthand CSS
*
* Convert longhand CSS properties to shorthand in `style` attributes.
*/
Expand All @@ -159,7 +150,7 @@ export async function run(html = '', config = {}) {
}

/**
* 11. Add attributes
* 10. Add attributes
*
* Add attributes to HTML tags.
*/
Expand All @@ -170,7 +161,7 @@ export async function run(html = '', config = {}) {
}

/**
* 12. Base URL
* 11. Base URL
*
* Add a base URL to relative paths.
*/
Expand All @@ -181,7 +172,7 @@ export async function run(html = '', config = {}) {
}

/**
* 13. URL parameters
* 12. URL parameters
*
* Add parameters to URLs.
*/
Expand All @@ -192,7 +183,7 @@ export async function run(html = '', config = {}) {
}

/**
* 14. Six-digit HEX
* 13. Six-digit HEX
*
* Enabled by default, converts three-digit HEX colors to six-digit.
*/
Expand All @@ -203,7 +194,7 @@ export async function run(html = '', config = {}) {
}

/**
* 15. PostHTML MSO
* 14. PostHTML MSO
*
* Enabled by default, simplifies writing MSO conditionals for Outlook.
*/
Expand All @@ -214,7 +205,23 @@ export async function run(html = '', config = {}) {
}

/**
* 16. Prettify
* 15. Purge CSS
*
* Remove unused CSS, uglify classes etc.
*/
if (get(config, 'css.purge')) {
posthtmlPlugins.push(comb(config.css.purge))
}

/**
* 16. <template> tags
*
* Replace <template> tags with their content.
*/
posthtmlPlugins.push(templateTag())

/**
* 17. Prettify
*
* Pretty-print HTML using js-beautify.
*/
Expand All @@ -225,7 +232,7 @@ export async function run(html = '', config = {}) {
}

/**
* 17. Minify
* 18. Minify
*
* Minify HTML using html-crush.
*/
Expand All @@ -235,13 +242,6 @@ export async function run(html = '', config = {}) {
)
}

/**
* 18. <template> tags
*
* Replace <template> tags with their content.
*/
posthtmlPlugins.push(templateTag())

/**
* 19. Replace strings
*
Expand Down

0 comments on commit 4a24a9b

Please sign in to comment.