@undp/create-app 0.2.11 → 0.2.13
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: [
|
|
@@ -65,6 +66,55 @@ export default defineConfig({
|
|
|
65
66
|
const mediaRules = [];
|
|
66
67
|
const containerRules = [];
|
|
67
68
|
|
|
69
|
+
function extractMinWidth(params) {
|
|
70
|
+
let match = params.match(/min-width:\s*([\d.]+)(px|rem)/);
|
|
71
|
+
if (!match) {
|
|
72
|
+
match = params.match(/width\s*>=\s*([\d.]+)(px|rem)/);
|
|
73
|
+
}
|
|
74
|
+
if (!match) return null;
|
|
75
|
+
|
|
76
|
+
const value = parseFloat(match[1]);
|
|
77
|
+
const unit = match[2];
|
|
78
|
+
return unit === 'rem' ? value * 16 : value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
root.walkAtRules(rule => {
|
|
82
|
+
if (rule.name !== 'media' && rule.name !== 'container') return;
|
|
83
|
+
|
|
84
|
+
const pxValue = extractMinWidth(rule.params);
|
|
85
|
+
if (pxValue === null) return;
|
|
86
|
+
|
|
87
|
+
const entry = {
|
|
88
|
+
pxValue,
|
|
89
|
+
rule: rule.clone(),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (rule.name === 'media') {
|
|
93
|
+
mediaRules.push(entry);
|
|
94
|
+
} else {
|
|
95
|
+
containerRules.push(entry);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
rule.remove();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// 1. Append media first
|
|
102
|
+
mediaRules
|
|
103
|
+
.sort((a, b) => a.pxValue - b.pxValue)
|
|
104
|
+
.forEach(({ rule }) => root.append(rule));
|
|
105
|
+
|
|
106
|
+
// 2. Append container after
|
|
107
|
+
containerRules
|
|
108
|
+
.sort((a, b) => a.pxValue - b.pxValue)
|
|
109
|
+
.forEach(({ rule }) => root.append(rule));
|
|
110
|
+
},
|
|
111
|
+
},` : `
|
|
112
|
+
{
|
|
113
|
+
postcssPlugin: 'move-responsive-queries',
|
|
114
|
+
OnceExit(root) {
|
|
115
|
+
const mediaRules = [];
|
|
116
|
+
const containerRules = [];
|
|
117
|
+
|
|
68
118
|
function extractMinWidth(params) {
|
|
69
119
|
const match = params.match(/min-width:\s*([\d.]+)(px|rem)/);
|
|
70
120
|
if (!match) return null;
|
|
@@ -104,7 +154,8 @@ export default defineConfig({
|
|
|
104
154
|
.sort((a, b) => a.pxValue - b.pxValue)
|
|
105
155
|
.forEach(({ rule }) => root.append(rule));
|
|
106
156
|
},
|
|
107
|
-
},`
|
|
157
|
+
},`
|
|
158
|
+
}
|
|
108
159
|
],
|
|
109
160
|
},
|
|
110
161
|
},
|
package/bin/promptUser.js
CHANGED
|
@@ -81,7 +81,7 @@ export async function promptUser(name) {
|
|
|
81
81
|
type: 'list',
|
|
82
82
|
name: 'postCSS',
|
|
83
83
|
message: chalk.yellow(
|
|
84
|
-
'⚙️ Add PostCSS script to
|
|
84
|
+
'⚙️ Add PostCSS script to wrap all classes in `.undp-container` (recommended if embedding in another app)?'
|
|
85
85
|
),
|
|
86
86
|
choices: ['Yes', 'No'],
|
|
87
87
|
default: 'Yes',
|