Comments (2)
Status Update
Running locally:
yarn build && env GATRACKINGID=<value> yarn start
Adding console.log()
to WithAnalytics.js
the value returns as undefined in the browser; but populates in the terminal. Possibly a SSR issue with React. Looking into more.
Thanks to @jamo for his assistance in debugging!
from my-blog.
Status Update
The temporary fix...maybe permanent is to follow this example it works...but I don't like it and got this idea so I want to roll with it 😄
Trying something a little different on this branch
The Plan
Use next.config.js
to create a custom webpack
config. In doing so I am offered the config object from next
. Performing a console.log(config)
I found I can access the DefinePlugin()
from the object. Doing the following, I can spread the environment variable to be added to the next
webpack.config. Providing the env var to it at time of deployment through now.env
or the CLI.
Rest of code is here
Object.assign(config.plugins[4].definitions, {
'process.env.GATRACKINGID': JSON.stringify(process.env.GATRACKINGID)
})
The code works locally when providing the env var via CLI:
env ENVVAR=env_var yarn build && yarn start
# next build && NODE_ENV=production node index.js
The working reality with now
& next
for deployment...not so much. 😩 😢
What I know from looking at the source code
- Calling
now
runsnow deploy
by default. - The
now deploy
script calls the prototypecreate()
from a new instance of theNow
class. - This method looks to be what is responsible for creating the instance of my code base and deploying it to Zeit's servers.
Questions
- Where is the
"build"
script being called at?
I see that here the method is looking for one of the three to be present. So I am assuming (never a good thing) that somewhere in the start script it is being called by
next
...I just haven't found it yet.
After reviewing the source code it looks as if now
looks through all options and configs prior to running a start script, or build script. If that is the case and what I am reading is correct here then the environment variables being set in the package.json
should be available at the time the next.config.js
is being used for the build process.
What I need to know
- process of scripts and commands being ran at
now
usage. - if the build process is happening concurrent to
now deploy
. - is this even worth time exploring or should I be shot down immediately 😂
from my-blog.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from my-blog.