-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serve static pages from app.yaml #6974
Changes from 17 commits
0bc53bb
df266a2
8b63d34
9106197
6d2cdb9
77fc41d
e3f24b7
fff201a
9baa459
3458a6b
6df30d8
a209b4e
7ccbf19
04bd338
f27d23b
c6617b5
81922b9
9104bca
abddd81
33c6f79
d99be7c
bd7eca5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,13 +105,20 @@ | |
# hash). | ||
# This is because these files don't need cache invalidation, are referenced | ||
# from third party files or should not be moved to the build directory. | ||
# Statically served pages from app.yaml should be here to since they don't | ||
# need cache invalidation. | ||
FILEPATHS_NOT_TO_RENAME = ( | ||
'*.py', | ||
'third_party/generated/fonts/*', | ||
'third_party/generated/js/third_party.min.js.map', | ||
'third_party/generated/webfonts/*', | ||
'*.bundle.js', | ||
'*.bundle.js.map') | ||
'*.bundle.js.map', | ||
'*/dist/get-started-page.mainpage.html', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the comment to explain why these files are present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
'*/dist/splash-page.mainpage.html', | ||
'*/dist/splash_at0.html', | ||
'*/dist/splash_at1.html', | ||
'*/dist/teach-page.mainpage.html') | ||
|
||
# Hashes for files with these paths should be provided to the frontend in | ||
# JS hashes object. | ||
|
@@ -122,6 +129,25 @@ | |
HASH_BLOCK_SIZE = 2**20 | ||
|
||
|
||
def generate_app_yaml(): | ||
"""Generate app.yaml from app_dev.yaml.""" | ||
dev_file_prefix = 'core/templates/dev/head' | ||
prod_file_prefix = 'build/templates/head' | ||
content = '# THIS FILE IS AUTOGENERATED, DO NOT MODIFY\n' | ||
with open('app_dev.yaml', 'r') as yaml_file: | ||
content += yaml_file.read() | ||
for file_path in FILEPATHS_NOT_TO_RENAME: | ||
if '/dist/' in file_path: | ||
content = content.replace( | ||
dev_file_prefix + file_path[1:], | ||
prod_file_prefix + file_path[1:]) | ||
content = content.replace('version: default', '') | ||
if os.path.isfile('app.yaml'): | ||
os.remove('app.yaml') | ||
with open('app.yaml', 'w+') as prod_yaml_file: | ||
prod_yaml_file.write(content) | ||
|
||
|
||
def require_compiled_js_dir_to_be_valid(): | ||
"""Checks if COMPILED_JS_DIR matches the output directory used in | ||
TSCONFIG_FILEPATH. | ||
|
@@ -1302,6 +1328,7 @@ def build(): | |
if options.prod_mode: | ||
build_using_webpack() | ||
minify_third_party_libs(THIRD_PARTY_GENERATED_DEV_DIR) | ||
generate_app_yaml() | ||
if not options.minify_third_party_libs_only: | ||
generate_build_directory() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanlip, the tests are here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you assert for something that should exist in the page (to make sure it's not serving a 404)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done