From 1fc87fa8b6805787bea28513ce73d54dc7f91e6b Mon Sep 17 00:00:00 2001 From: felixren Date: Tue, 18 Jun 2024 18:13:38 +0800 Subject: [PATCH 1/2] fix: in postcss 8+, postcss.atrule has become postcss.Atrule --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6419322..c845ea4 100755 --- a/index.js +++ b/index.js @@ -134,7 +134,7 @@ module.exports = postcss.plugin('postcss-px-to-viewport', function (options) { }); if (landscapeRules.length > 0) { - var landscapeRoot = new postcss.atRule({ params: '(orientation: landscape)', name: 'media' }); + var landscapeRoot = new postcss.AtRule({ params: '(orientation: landscape)', name: 'media' }); landscapeRules.forEach(function(rule) { landscapeRoot.append(rule); From 59fbf39faf5b6b3e19eae63acf5ccc25ec281030 Mon Sep 17 00:00:00 2001 From: felixren Date: Tue, 18 Jun 2024 18:27:20 +0800 Subject: [PATCH 2/2] fix: better compatibility with lower versions --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c845ea4..b9de6fe 100755 --- a/index.js +++ b/index.js @@ -134,7 +134,8 @@ module.exports = postcss.plugin('postcss-px-to-viewport', function (options) { }); if (landscapeRules.length > 0) { - var landscapeRoot = new postcss.AtRule({ params: '(orientation: landscape)', name: 'media' }); + var atRule = postcss.AtRule || postcss.atRule + var landscapeRoot = atRule({ params: '(orientation: landscape)', name: 'media' }); landscapeRules.forEach(function(rule) { landscapeRoot.append(rule);