Skip to content

Commit 7e06fb3

Browse files
committed
feat(css): remove auto-inject css
because of strict CSP issues, inejcted styles cannot be applied on some environments (see #332) BREAKING CHANGE: when migrating, ensure to import vue3-select-component/style into your project, where you are using the component
1 parent 8dec6ce commit 7e06fb3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

package-lock.json

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"types": "./dist/index.d.ts",
2020
"import": "./dist/index.es.js",
2121
"require": "./dist/index.umd.js"
22+
},
23+
"./styles": {
24+
"import": "./dist/styles.css",
25+
"require": "./dist/styles.css"
2226
}
2327
},
2428
"main": "dist/index.umd.js",
@@ -66,7 +70,6 @@
6670
"postcss": "8.5.6",
6771
"typescript": "5.9.2",
6872
"vite": "7.1.12",
69-
"vite-plugin-css-injected-by-js": "3.5.2",
7073
"vite-plugin-dts": "4.5.4",
7174
"vite-plugin-vue-devtools": "8.0.3",
7275
"vitepress": "1.6.4",

vite.config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { resolve as pathResolve } from "node:path";
44
import { fileURLToPath, URL } from "node:url";
55
import vue from "@vitejs/plugin-vue";
66
import { defineConfig } from "vite";
7-
import cssInject from "vite-plugin-css-injected-by-js";
87
import dts from "vite-plugin-dts";
98
import vueDevtools from "vite-plugin-vue-devtools";
109

@@ -29,7 +28,6 @@ export default defineConfig((configEnv) => {
2928

3029
plugins: [
3130
...config.plugins!,
32-
cssInject(),
3331
dts({ tsconfigPath: "tsconfig.build.json", cleanVueFileName: true }),
3432
],
3533

@@ -45,7 +43,17 @@ export default defineConfig((configEnv) => {
4543
},
4644
rollupOptions: {
4745
external: ["vue"],
48-
output: { globals: { vue: "Vue" } },
46+
output: {
47+
globals: { vue: "Vue" },
48+
// Change default name of the .css file built.
49+
assetFileNames: (assetInfo) => {
50+
if (assetInfo.names.includes("vue3-select-component.css")) {
51+
return "styles.css";
52+
}
53+
54+
return assetInfo.names[0];
55+
},
56+
},
4957
},
5058
},
5159
};

0 commit comments

Comments
 (0)