我已经使用React从头开始构建了一个项目,并将其部署到ZEIT。在开发模式下,.env文件中的所有变量都已加载(使用dotenv-webpack),一切正常。 默认情况下,ZEIT Now将在生产环境中忽略.env,因此我将所有.env变量都这样放置到now.json
{ "version": 2, "alias": "goccuathi", "regions": [ "sin1" ], "build": { "env": { "OWNER_EMAIL": "@gct_owner-email", "TINYMCE_KEY": "@gct_tinymce-key", "GA_ID": "@gct_ga-key" } }, "env": { "OWNER_EMAIL": "@gct_owner-email", "TINYMCE_KEY": "@gct_tinymce-key", "GA_ID": "@gct_ga-key" } }
这是日志:
{"id":"dpl_2wDwTfqRGa46WYsCeSh31zmsHnke","lambdas":[{"id":"bld_pw942tu0q","createdAt":1585988984285,"entrypoint":"package.json","readyState":"INITIALIZING","readyStateAt":1585988984285,"output":[]}],"public":false,"readyState":"QUEUED","regions":["sin1"],"url":"goccuathi-9mtrc5d9i.now.sh","version":2,"build":{"env":["OWNER_EMAIL","TINYMCE_KEY","GA_ID"]},"builds":[{"src":"package.json","use":"@now/static-build","config":{"zeroConfig":true}}],"createdAt":1585988983745,"createdIn":"sfo1","env":[],"meta":{},"name":"goccuathi","ownerId":"cYIfFUzo4cG4SkSwFNEEOLE5","plan":"hobby","routes":[],"target":"production","functions":null,"projectId":"QmcrHSmFE6x35GgZuxnkkQfJdjW3K5RjKG1yNL4EBrxgjm","type":"LAMBDAS","team":null,"creator":{"uid":"cYIfFUzo4cG4SkSwFNEEOLE5","username":"anhthi-ieig"},"bootedAt":1585988983745,"buildingAt":1585988983745,"status":"QUEUED","alias":["goccuathi.now.sh","goccuathi.anhthi-ieig.now.sh"],"aliasAssigned":false}
我在生产中的.env变量为空。 我究竟做错了什么?