vite-plugin-css-position 2.0.4 → 2.0.6
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.
- package/README.md +3 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ Add the plugin to your `vite.config.ts`:
|
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
37
|
...
|
|
38
|
-
import {
|
|
38
|
+
import { viteCssPosition } from "vite-plugin-css-position";
|
|
39
39
|
|
|
40
40
|
export default defineConfig({
|
|
41
|
-
plugins: [react(), /* or vue(), */
|
|
41
|
+
plugins: [react(), /* or vue(), */ viteCssPosition()],
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -82,7 +82,7 @@ That's it! Your stylesheets will now be injected at the position of the `<Styles
|
|
|
82
82
|
The plugin accepts optional configuration:
|
|
83
83
|
|
|
84
84
|
```typescript
|
|
85
|
-
|
|
85
|
+
viteCssPosition({
|
|
86
86
|
enableDev: true,
|
|
87
87
|
});
|
|
88
88
|
```
|
|
@@ -103,12 +103,6 @@ npm run play
|
|
|
103
103
|
|
|
104
104
|
# Build the library
|
|
105
105
|
npm run build
|
|
106
|
-
|
|
107
|
-
# Run tests
|
|
108
|
-
npm test
|
|
109
|
-
|
|
110
|
-
# Type check
|
|
111
|
-
npm run typecheck
|
|
112
106
|
```
|
|
113
107
|
|
|
114
108
|
## 📝 License
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ interface ViteCustomCssPositionOptions {
|
|
|
7
7
|
}
|
|
8
8
|
declare function viteCustomCssPosition(options?: ViteCustomCssPositionOptions): Plugin | Plugin[];
|
|
9
9
|
//#endregion
|
|
10
|
-
export { type ViteCustomCssPositionOptions, viteCustomCssPosition as viteReactCssPosition };
|
|
10
|
+
export { type ViteCustomCssPositionOptions, viteCustomCssPosition as viteCssPosition, viteCustomCssPosition as viteReactCssPosition };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,8 @@ import e from"vite-plugin-css-injected-by-js";import{hash as t,randomUUID as n}f
|
|
|
5
5
|
window.dispatchEvent( new Event('${o}') );
|
|
6
6
|
}
|
|
7
7
|
})()
|
|
8
|
-
`}},injectCode:(e,n)=>{let r=JSON.stringify(n.attributes||{});return`
|
|
9
|
-
const css = ${e};
|
|
10
|
-
const id = ${`"${n.attributes?.[`data-vite-dev-id`]??t(`sha1`,e).substring(0,12)}"`};
|
|
11
|
-
const attributes = JSON.parse('${r}');
|
|
8
|
+
`}},injectCode:(e,n)=>{let r=JSON.stringify(n.attributes||{});return`const css = ${e};const id = ${`"${n.attributes?.[`data-vite-dev-id`]??t(`sha1`,e).substring(0,12)}"`};const attributes = JSON.parse('${r}');
|
|
12
9
|
window.${a} = window.${a} || new Map();
|
|
13
10
|
window.${a}.set(id, {css, attributes});
|
|
14
|
-
|
|
15
|
-
window.dispatchEvent( new Event('${o}') );
|
|
16
|
-
`}});return[{name:`vite-plugin-custom-css-position`,config(e){return{...e,define:{...e.define,__VITE_CSS_POS_GLOBAL_VAR_NAME__:JSON.stringify(a),__VITE_CSS_POS_EVENT_NAME__:JSON.stringify(o)}}}},...Array.isArray(s)?s:[s]]}export{r as viteReactCssPosition};
|
|
11
|
+
window.dispatchEvent( new Event('${o}') );`}});return[{name:`vite-plugin-custom-css-position`,config(e){return{...e,define:{...e.define,__VITE_CSS_POS_GLOBAL_VAR_NAME__:JSON.stringify(a),__VITE_CSS_POS_EVENT_NAME__:JSON.stringify(o)}}}},...Array.isArray(s)?s:[s]]}export{r as viteCssPosition,r as viteReactCssPosition};
|
|
17
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/viteCustomCssPosition.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport cssInjectedByJsPlugin from \"vite-plugin-css-injected-by-js\";\nimport { randomUUID, hash } from \"crypto\";\n\nexport interface ViteCustomCssPositionOptions {\n instanceId?: string;\n enableDev?: boolean;\n}\n\nexport default function viteCustomCssPosition(\n options?: ViteCustomCssPositionOptions\n): Plugin | Plugin[] {\n const instanceId = options?.instanceId || randomUUID().replace(/-/g, \"\");\n\n const globalVarName = `__vite_c_css_pos_initial_${instanceId}`;\n const eventName = `__vite_c_css_pos_update_${instanceId}`;\n\n const cssPlugin = cssInjectedByJsPlugin({\n dev: {\n enableDev: options?.enableDev ?? false,\n removeStyleCode(id: string) {\n return `\n (() => {\n if(window.${globalVarName} && window.${globalVarName}.has('${id}')) {\n window.${globalVarName}.delete('${id}');\n window.dispatchEvent( new Event('${eventName}') );\n }\n })()\n `;\n },\n },\n injectCode: (css, attributes) => {\n const attributesString = JSON.stringify(attributes.attributes || {});\n const id = `\"${\n attributes.attributes?.[\"data-vite-dev-id\"] ??\n hash(\"sha1\", css).substring(0, 12)\n }\"`;\n return
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/viteCustomCssPosition.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport cssInjectedByJsPlugin from \"vite-plugin-css-injected-by-js\";\nimport { randomUUID, hash } from \"crypto\";\n\nexport interface ViteCustomCssPositionOptions {\n instanceId?: string;\n enableDev?: boolean;\n}\n\nexport default function viteCustomCssPosition(\n options?: ViteCustomCssPositionOptions\n): Plugin | Plugin[] {\n const instanceId = options?.instanceId || randomUUID().replace(/-/g, \"\");\n\n const globalVarName = `__vite_c_css_pos_initial_${instanceId}`;\n const eventName = `__vite_c_css_pos_update_${instanceId}`;\n\n const cssPlugin = cssInjectedByJsPlugin({\n dev: {\n enableDev: options?.enableDev ?? false,\n removeStyleCode(id: string) {\n return `\n (() => {\n if(window.${globalVarName} && window.${globalVarName}.has('${id}')) {\n window.${globalVarName}.delete('${id}');\n window.dispatchEvent( new Event('${eventName}') );\n }\n })()\n `;\n },\n },\n injectCode: (css, attributes) => {\n const attributesString = JSON.stringify(attributes.attributes || {});\n const id = `\"${\n attributes.attributes?.[\"data-vite-dev-id\"] ??\n hash(\"sha1\", css).substring(0, 12)\n }\"`;\n return `const css = ${css};const id = ${id};const attributes = JSON.parse('${attributesString}');\n window.${globalVarName} = window.${globalVarName} || new Map();\n window.${globalVarName}.set(id, {css, attributes});\n window.dispatchEvent( new Event('${eventName}') );`;\n },\n });\n\n return [\n {\n name: \"vite-plugin-custom-css-position\",\n config(c) {\n return {\n ...c,\n define: {\n ...c.define,\n __VITE_CSS_POS_GLOBAL_VAR_NAME__: JSON.stringify(globalVarName),\n __VITE_CSS_POS_EVENT_NAME__: JSON.stringify(eventName),\n },\n };\n },\n },\n ...(Array.isArray(cssPlugin) ? cssPlugin : [cssPlugin]),\n ];\n}\n"],"mappings":"4FASA,SAAwB,EACtB,EACmB,CACnB,IAAM,EAAa,GAAS,YAAc,GAAY,CAAC,QAAQ,KAAM,GAAG,CAElE,EAAgB,4BAA4B,IAC5C,EAAY,2BAA2B,IAEvC,EAAY,EAAsB,CACtC,IAAK,CACH,UAAW,GAAS,WAAa,GACjC,gBAAgB,EAAY,CAC1B,MAAO;;sBAEO,EAAc,aAAa,EAAc,QAAQ,EAAG;qBACrD,EAAc,WAAW,EAAG;+CACF,EAAU;;;aAKpD,CACD,YAAa,EAAK,IAAe,CAC/B,IAAM,EAAmB,KAAK,UAAU,EAAW,YAAc,EAAE,CAAC,CAKpE,MAAO,eAAe,EAAI,cAJf,IACT,EAAW,aAAa,qBACxB,EAAK,OAAQ,EAAI,CAAC,UAAU,EAAG,GAAG,CACnC,GAC0C,kCAAkC,EAAiB;eACrF,EAAc,YAAY,EAAc;eACxC,EAAc;yCACY,EAAU,QAEhD,CAAC,CAEF,MAAO,CACL,CACE,KAAM,kCACN,OAAO,EAAG,CACR,MAAO,CACL,GAAG,EACH,OAAQ,CACN,GAAG,EAAE,OACL,iCAAkC,KAAK,UAAU,EAAc,CAC/D,4BAA6B,KAAK,UAAU,EAAU,CACvD,CACF,EAEJ,CACD,GAAI,MAAM,QAAQ,EAAU,CAAG,EAAY,CAAC,EAAU,CACvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-css-position",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Custom position of vite styles within a vite react app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/Ahn1/vite-plugin-css-position.git"
|
|
14
14
|
},
|
|
15
|
+
"tags": [
|
|
16
|
+
"vite",
|
|
17
|
+
"css",
|
|
18
|
+
"position",
|
|
19
|
+
"react",
|
|
20
|
+
"vue",
|
|
21
|
+
"shadow-dom"
|
|
22
|
+
],
|
|
15
23
|
"author": "Alexander Bogoslawski <alexanderb@posteo.de>",
|
|
16
24
|
"files": [
|
|
17
25
|
"dist"
|