forked from kevadesu/forgejo
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.
This commit is contained in:
parent
6375419468
commit
62f3c0fe76
3 changed files with 12 additions and 39 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue