Skip to content

Commit

Permalink
Switch to vite-string-plugin (#25762)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
silverwind authored Jul 8, 2023
1 parent 6375419 commit 62f3c0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
33 changes: 10 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
Expand Down
16 changes: 1 addition & 15 deletions vitest.config.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down

0 comments on commit 62f3c0f

Please sign in to comment.