How do I use @rollup/plugin-inject (or something similar) to inject global functions? #27079
Unanswered
StephanBijzitter
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Using Storybook 7 with
@vitejs/plugin-react-swc
My problem is two-fold:
My stories (some of them) depend on files that use a globally injected function
__
(using webpack) to translate variables, a very truncated example would be:Other stories depend on Dexie to load data from indexedDB, but I want to use fake-indexeddb to make sure the stories are the same for everyone and don't depend on what data they happen to have available.
With
@rollup/plugin-inject
I expected every file using__
to haveimport {__} from '...path.../translations-shim.ts';
injected into them and the file that sets up dexie to have injectedimport {indexedDB} from 'fake-indexeddb'
into it,but... it doesn't seem to do anything at all. What am I doing wrong?
Additional information
Create a reproduction
If really needed I can set one up
Beta Was this translation helpful? Give feedback.
All reactions