aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-07-08 06:56:12 +0200
committerGitHub <noreply@github.com>2023-07-08 04:56:12 +0000
commit62f3c0fe76f215cbe88b1a76408b09d74ad14f92 (patch)
tree3ef6dc06bc8a9afa5fa35136870c18b400cb0d0b
parent6375419468edc95fdfac94aac3b0e10b23743557 (diff)
downloadgitea-62f3c0fe76f215cbe88b1a76408b09d74ad14f92.tar.gz
gitea-62f3c0fe76f215cbe88b1a76408b09d74ad14f92.zip
Switch to `vite-string-plugin` (#25762)
Switch to [`vite-string-plugin`](https://github.com/silverwind/vite-string-plugin) to load SVGs as string during tests. The plugin will also be useful once we switch to vite.
-rw-r--r--package-lock.json33
-rw-r--r--package.json2
-rw-r--r--vitest.config.js16
3 files changed, 12 insertions, 39 deletions
diff --git a/package-lock.json b/package-lock.json
index 2db1ec6607..c904826b18 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -56,7 +56,6 @@
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "3.2.1",
"@playwright/test": "1.35.1",
- "@rollup/pluginutils": "5.0.2",
"@stoplight/spectral-cli": "6.8.0",
"@vitejs/plugin-vue": "4.2.3",
"eslint": "8.43.0",
@@ -80,6 +79,7 @@
"stylelint-stylistic": "0.4.2",
"svgo": "3.0.2",
"updates": "14.2.8",
+ "vite-string-plugin": "1.1.0",
"vitest": "0.32.2"
},
"engines": {
@@ -1294,28 +1294,6 @@
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
"dev": true
},
- "node_modules/@rollup/pluginutils": {
- "version": "5.0.2",
- "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz",
- "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==",
- "dev": true,
- "dependencies": {
- "@types/estree": "^1.0.0",
- "estree-walker": "^2.0.2",
- "picomatch": "^2.3.1"
- },
- "engines": {
- "node": ">=14.0.0"
- },
- "peerDependencies": {
- "rollup": "^1.20.0||^2.0.0||^3.0.0"
- },
- "peerDependenciesMeta": {
- "rollup": {
- "optional": true
- }
- }
- },
"node_modules/@stoplight/better-ajv-errors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-1.0.3.tgz",
@@ -10743,6 +10721,15 @@
"url": "https://opencollective.com/vitest"
}
},
+ "node_modules/vite-string-plugin": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/vite-string-plugin/-/vite-string-plugin-1.1.0.tgz",
+ "integrity": "sha512-RMxstCLl6Zyyz4tkzzHDFrrVvom1GAxjo2lTmgfus5CZYOnFNcJ2iQiDaFpc4KAOHSNkBNtkj5YauSs+f1gqCA==",
+ "dev": true,
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/vite/node_modules/rollup": {
"version": "3.25.3",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.3.tgz",
diff --git a/package.json b/package.json
index 0866f7e2a1..aa8c04fb6e 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,6 @@
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "3.2.1",
"@playwright/test": "1.35.1",
- "@rollup/pluginutils": "5.0.2",
"@stoplight/spectral-cli": "6.8.0",
"@vitejs/plugin-vue": "4.2.3",
"eslint": "8.43.0",
@@ -79,6 +78,7 @@
"stylelint-stylistic": "0.4.2",
"svgo": "3.0.2",
"updates": "14.2.8",
+ "vite-string-plugin": "1.1.0",
"vitest": "0.32.2"
},
"browserslist": [
diff --git a/vitest.config.js b/vitest.config.js
index 169a783fdd..0b3a210948 100644
--- a/vitest.config.js
+++ b/vitest.config.js
@@ -1,20 +1,6 @@
import {defineConfig} from 'vitest/dist/config.js';
-import {readFile} from 'node:fs/promises';
-import {dataToEsm} from '@rollup/pluginutils';
-import {extname} from 'node:path';
import vue from '@vitejs/plugin-vue';
-
-function stringPlugin() {
- return {
- name: 'string-plugin',
- enforce: 'pre',
- async load(id) {
- const path = id.split('?')[0];
- if (extname(path) !== '.svg') return null;
- return dataToEsm(await readFile(path, 'utf8'));
- }
- };
-}
+import {stringPlugin} from 'vite-string-plugin';
export default defineConfig({
test: {