@undp/create-app 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,8 @@ import eslint from '@nabla/vite-plugin-eslint';
6
6
  import { visualizer } from 'rollup-plugin-visualizer';
7
7
  import postcssNested from 'postcss-nested';
8
8
  import tailwindcss from '@tailwindcss/postcss';${config.addStaticWebAppConfig ? `
9
- import { viteStaticCopy } from 'vite-plugin-static-copy';` : ''}
9
+ import { viteStaticCopy } from 'vite-plugin-static-copy';` : ''}${config.addPostCSSScripts ? `
10
+ import { AtRule } from 'postcss';` : ''}
10
11
 
11
12
  export default defineConfig({
12
13
  plugins: [
@@ -60,32 +61,49 @@ export default defineConfig({
60
61
  },
61
62
  },
62
63
  {
63
- postcssPlugin: 'move-media-queries-by-breakpoint',
64
+ postcssPlugin: 'move-responsive-queries',
64
65
  OnceExit(root) {
65
66
  const mediaRules = [];
67
+ const containerRules = [];
66
68
 
67
- root.walkAtRules('media', rule => {
68
- const match = rule.params.match(/min-width:\s*([\d.]+)(px|rem)/);
69
-
70
- if (!match) return;
69
+ function extractMinWidth(params) {
70
+ const match = params.match(/min-width:\s*([\d.]+)(px|rem)/);
71
+ if (!match) return null;
71
72
 
72
73
  const value = parseFloat(match[1]);
73
74
  const unit = match[2];
75
+ return unit === 'rem' ? value * 16 : value;
76
+ }
77
+
78
+ root.walkAtRules(rule => {
79
+ if (rule.name !== 'media' && rule.name !== 'container') return;
74
80
 
75
- // Normalize to px (assuming 16px root for sorting)
76
- const pxValue = unit === 'rem' ? value * 16 : value;
81
+ const pxValue = extractMinWidth(rule.params);
82
+ if (pxValue === null) return;
77
83
 
78
- mediaRules.push({
84
+ const entry = {
79
85
  pxValue,
80
86
  rule: rule.clone(),
81
- });
87
+ };
88
+
89
+ if (rule.name === 'media') {
90
+ mediaRules.push(entry);
91
+ } else {
92
+ containerRules.push(entry);
93
+ }
82
94
 
83
95
  rule.remove();
84
96
  });
85
97
 
98
+ // 1. Append media first
86
99
  mediaRules
87
100
  .sort((a, b) => a.pxValue - b.pxValue)
88
101
  .forEach(({ rule }) => root.append(rule));
102
+
103
+ // 2. Append container after
104
+ containerRules
105
+ .sort((a, b) => a.pxValue - b.pxValue)
106
+ .forEach(({ rule }) => root.append(rule));
89
107
  },
90
108
  },` : ''}
91
109
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undp/create-app",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "UNDP's project scaffolding tool",
5
5
  "bin": {
6
6
  "create-undp-app": "./bin/index.js"