I've been trying to use the `StaticSite` construct...
# help
a
I've been trying to use the
StaticSite
construct and environment variables and it seems that it sets the variables with
{{ VARIABLE }}
rather than actually setting the variable, and after build it will inject the variable using some type of text match/find-replace. The problem is that in some static sites, the build happens via webpack and process.env.VARIABLE is handled via webpack's
definePlugin
module, which expects the actual value to be set before the build process. Has anyone faced this issue? If yes, how have you solved it? Any help would be appreciated.
t
Unfortunately it has to work this way because none ofthe stack code is actually doing anything when it runs. This all happens BEFORE anything is sent to AWS
So we have to use this replacement scheme to inject variables after it's deployed
can you tell me more what issue webpack has with this? We're using this with create-react-app which uses webpack + other tools (snowpack vite) without issue
a
webpack essentially does the same thing, I may get away by remove the define plugin in webpack
it's also happening at build time, before the code is deployed
The DefinePlugin replaces variables in your code with other values or expressions at compile time.
let me try removing definePlugin
t
ah if you use this with
sst-env
you don't need the definePlugin
a
yah