Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

Contain CSS file in the published package (#417)

Jiachi Liu85b830fceafd
diff --git a/.gitignore b/.gitignore
index ba3cd53..2ae76a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,6 @@ yarn-error.log*
/test-results/
/playwright-report/
/playwright/.cache/
+
+# styles
+style.css
diff --git a/README.md b/README.md
index 5609976..0a5c1fb 100644
--- a/README.md
+++ b/README.md
@@ -146,3 +146,9 @@ The button that closes the dialog. [Props](https://www.radix-ui.com/docs/primiti
### Portal
Portals your drawer into the body.
+
+### CSS File
+
+CSS in this library is inserted by JavaScript into `<head>` element by default. If you're having issue with it such as [CSP restriction](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src), you can use `vaul/style.css` CSS as a workaround to apply the styles.
+
+> Note: You don't need to import it unless the default inline styles is blocked by CSP.
diff --git a/package.json b/package.json
index 3919b02..6cfd356 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,8 @@
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
- "dist"
+ "dist",
+ "style.css"
],
"exports": {
"import": {
@@ -20,7 +21,8 @@
},
"scripts": {
"type-check": "tsc --noEmit",
- "build": "pnpm type-check && bunchee",
+ "build": "pnpm type-check && bunchee && pnpm copy-assets",
+ "copy-assets": "cp -r ./src/style.css ./style.css",
"dev": "bunchee --watch",
"dev:website": "turbo run dev --filter=website...",
"dev:test": "turbo run dev --filter=test...",