diff --git a/.storybook/preview.js b/.storybook/preview.js index 84e521937..a2b8c0d87 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -5,6 +5,7 @@ import 'design-token-editor/lib/css/dte.css'; import 'design-token-editor/lib/css/root.css'; import 'flatpickr'; import 'flatpickr/dist/l10n/nl.js'; +import lodash from 'lodash'; import {fixIconUrls as fixLeafletIconUrls} from 'map'; import {initialize, mswLoader} from 'msw-storybook-addon'; import {Formio, Templates} from 'react-formio'; @@ -28,6 +29,8 @@ import { import {reactIntl} from './reactIntl.mjs'; import ThemeProvider from './theme'; +window._ = lodash; + initialize({ onUnhandledRequest: 'bypass', serviceWorker: { diff --git a/vite.config.mts b/vite.config.mts index f3ca7b8b6..1f0ba6569 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -2,7 +2,6 @@ // https://vitejs.dev/config/ import react from '@vitejs/plugin-react'; import lodashTemplate from 'lodash/template'; -import {readFile} from 'node:fs/promises'; import {defineConfig} from 'vite'; import jsconfigPaths from 'vite-jsconfig-paths'; import {coverageConfigDefaults} from 'vitest/config'; @@ -11,7 +10,7 @@ import {coverageConfigDefaults} from 'vitest/config'; // https://github.com/difelice/ejs-loader/blob/master/index.js const ejsPlugin = () => ({ name: 'compile-ejs', - async transform(_, id) { + async transform(src: string, id: string) { const options = { variable: 'ctx', evaluate: /\{%([\s\S]+?)%\}/g, @@ -19,7 +18,6 @@ const ejsPlugin = () => ({ escape: /\{\{\{([\s\S]+?)\}\}\}/g, }; if (id.endsWith('.ejs')) { - const src = await readFile(id, 'utf-8'); // @ts-ignore const code = lodashTemplate(src, options); return {code: `export default ${code}`, map: null};