@antscorp/ama-ui 0.1.0 → 0.1.2
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.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Plugin as Plugin_2 } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin: `vite-plugin-strip-antd-mobile-styles`
|
|
5
|
+
*
|
|
6
|
+
* [Context]
|
|
7
|
+
* `antd-mobile` components each self-import their own styling files as a side effect
|
|
8
|
+
* (e.g., `es/components/button/index.js` executes `import "./button.css"`).
|
|
9
|
+
* If your project explicitly imports a centralized bundle instead (e.g., `antd-mobile/bundle/style.css`),
|
|
10
|
+
* or uses custom style definitions, these per-component imports will duplicate CSS assets,
|
|
11
|
+
* break CSS Cascade Layers, and bloat the production bundle size.
|
|
12
|
+
*
|
|
13
|
+
* [Solution]
|
|
14
|
+
* This plugin intercepts all styling import statements (.css, .less, .scss, etc.) originating from
|
|
15
|
+
* inside the `antd-mobile/es/` directory during the early `pre` resolution phase. It redirects
|
|
16
|
+
* these imports to an empty virtual module, effectively eliminating duplicate entries and ensuring
|
|
17
|
+
* antd-mobile's styles have a single controlled entry point.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stripAntdMobileStyles(): Plugin_2;
|
|
20
|
+
|
|
21
|
+
export { }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function n() {
|
|
2
|
+
const l = /\.(css|less|scss|sass|styl)(\?.*)?$/, s = "\0empty-antd-mobile-styles";
|
|
3
|
+
return { name: "vite-plugin-strip-antd-mobile-styles", enforce: "pre", resolveId(e, t) {
|
|
4
|
+
if (l.test(e) && t && t.includes("node_modules/antd-mobile/es/")) return s;
|
|
5
|
+
}, load(e) {
|
|
6
|
+
if (e === s) return "";
|
|
7
|
+
} };
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
n as stripAntdMobileStyles
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=vite-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugins.js","sources":["../vite-plugins/strip-antd-component-css.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Vite plugin: `vite-plugin-strip-antd-mobile-styles`\n * \n * [Context]\n * `antd-mobile` components each self-import their own styling files as a side effect\n * (e.g., `es/components/button/index.js` executes `import \"./button.css\"`).\n * If your project explicitly imports a centralized bundle instead (e.g., `antd-mobile/bundle/style.css`),\n * or uses custom style definitions, these per-component imports will duplicate CSS assets, \n * break CSS Cascade Layers, and bloat the production bundle size.\n * \n * [Solution]\n * This plugin intercepts all styling import statements (.css, .less, .scss, etc.) originating from \n * inside the `antd-mobile/es/` directory during the early `pre` resolution phase. It redirects \n * these imports to an empty virtual module, effectively eliminating duplicate entries and ensuring \n * antd-mobile's styles have a single controlled entry point.\n */\nexport function stripAntdMobileStyles(): Plugin {\n // Matches all common styling extensions: .css, .less, .scss, .sass, .styl\n // The optional `(\\?.*)?$` handles cases where Vite appends query parameters (e.g., ?inline, ?used)\n const styleExtensionRegex = /\\.(css|less|scss|sass|styl)(\\?.*)?$/;\n\n // The unique identifier for our virtual empty module\n const VIRTUAL_EMPTY_STYLE_ID = \"\\0empty-antd-mobile-styles\";\n\n return {\n name: \"vite-plugin-strip-antd-mobile-styles\",\n\n // Runs in the 'pre' phase to intercept styles before other asset or transform plugins process them\n enforce: \"pre\",\n\n resolveId(source, importer) {\n // 1. Perform a quick regex check to see if the import source is a styling asset\n if (styleExtensionRegex.test(source)) {\n // 2. Verify if this style asset is being requested from within the 'antd-mobile/es/' package\n if (importer && importer.includes(\"node_modules/antd-mobile/es/\")) {\n // Redirect the path resolution to our empty virtual module\n return VIRTUAL_EMPTY_STYLE_ID;\n }\n }\n },\n\n load(id) {\n // If the module ID matches the virtual ID, return an empty string to strip out the style content\n if (id === VIRTUAL_EMPTY_STYLE_ID) {\n return \"\";\n }\n },\n };\n}\n"],"names":["stripAntdMobileStyles","styleExtensionRegex","VIRTUAL_EMPTY_STYLE_ID","name","enforce","source","importer","test","includes","id"],"mappings":"AAkBO,SAASA;AAGd,QAAMC,IAAsB,uCAGtBC,IAAyB;AAExB,SAAA,EACLC,MAAM,wCAGNC,SAAS,OAET,UAAUC,GAAQC;AAEZ,QAAAL,EAAoBM,KAAKF,CAAAA,KAEvBC,KAAYA,EAASE,SAAS,8BAEzB,EAAA,QAAAN;AAAAA,EAGb,GAEA,KAAKO,GAAAA;AAEH,QAAIA,MAAOP,EACF,QAAA;AAAA,EACT;AAGN;"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/ama-ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"main": "dist/ama-ui.es.js",
|
|
5
|
-
"module": "dist/ama-ui.es.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "0.1.2",
|
|
7
4
|
"exports": {
|
|
8
5
|
".": {
|
|
9
|
-
"types": "./dist/
|
|
6
|
+
"types": "./dist/ama-ui.d.ts",
|
|
10
7
|
"import": "./dist/ama-ui.es.js"
|
|
11
8
|
},
|
|
9
|
+
"./vite-plugins": {
|
|
10
|
+
"types": "./dist/vite-plugins.d.ts",
|
|
11
|
+
"import": "./dist/vite-plugins.js"
|
|
12
|
+
},
|
|
12
13
|
"./ama-ui.css": "./dist/ama-ui.css",
|
|
13
14
|
"./tailwind-theme.css": "./dist/tailwind-theme.css"
|
|
14
15
|
},
|
|
File without changes
|