previewjs
previewjs copied to clipboard
Support global vars injected by webpack.DefinePlugin
Is your feature request related to a problem? Please describe.
I'm getting undefined errors from some of my code that uses global vars defined with
webpack.DefinePlugin
https://webpack.js.org/plugins/define-plugin/
Describe the solution you'd like I want my vars to be loaded from the Wrapper component.
Describe alternatives you've considered Manually set up the vars, but that would be cumbersome and add code duplication.
Additional context None
Hi @wilomgfx, you might be able to make it work with the following in reactpreview.config.js
:
const reactpreview = require("@reactpreview/config");
module.exports = reactpreview.config({
vite: {
define: {
// ...
}
}
});
See https://vitejs.dev/config/#define for the corresponding Vite documentation.
I haven't tried this myself so not entirely sure whether this will work :) Let me know how you go!
Hi @wilomgfx, you might be able to make it work with the following in
reactpreview.config.js
:const reactpreview = require("@reactpreview/config"); module.exports = reactpreview.config({ vite: { define: { // ... } } });
See vitejs.dev/config/#define for the corresponding Vite documentation.
I haven't tried this myself so not entirely sure whether this will work :) Let me know how you go!
Hi,
Thanks for your response.
I will try it out this week and get back to you :)!