我正在使用create-react-app,在生产中,我想在s3上投放JS和CSS及其他静态资产,但从其他位置投放index.html文件。但是,生成文件中的URL都是相对路径。
是否有一种方法(不弹出)在生产版本中使用绝对URL?
答案 0 :(得分:0)
显然,这可以通过import sys
import time
import getopt
def main(argv):
global lineNbr, matchesNbr
print("\n")
try:
opts, args = getopt.getopt(argv,"hl:m:",["l=","m="])
except getopt.GetoptError:
print("Usage: matchstick.py -l <lines> -m <matches>")
sys.exit(2)
while True:
for opt, arg in opts:
elif opt in ("-l", "--lines"):
lines = int(arg)
if lines <= 1:
print("Error: you have to input at least two lines")
sys.exit()
if lines >= 100:
print("Error: Lines can't go more than 100!")
sys.exit()
print("\n")
print("***************")
for i in range(lines):
print("*| | | | | | |*")
elif opt in ("-m", "--matches"):
matchesDel = int(arg)
if matchesDel <= 0:
print("Error: value must be more than 0!")
sys.exit()
print("***************")
print("\n")
lineNbr = input("Line: ")
finalLine = int(lineNbr)
matchesNbr = input("Matches: ")
finalMatches = int(matchesNbr)
print("\n")
print("Player removed " + matchesNbr + " match(es) from line " + lineNbr)
print("\n")
print("AI's turn...")
time.sleep(3)
# ai delete something randomly
print("AI removed " + matchesNbr + " match(es) from line " + lineNbr)
if __name__ == "__main__":
main(sys.argv[1:])
环境变量来实现。我给人的印象是,如果React应用程序位于子目录中,则应使用此变量来修复客户端路由。但是,通过添加:
PUBLIC_URL
所有文件中的URL变为绝对URL,而不是相对URL。