parameter for turning off nextJS compression (#1316)
This commit is contained in:
parent
bb6be16963
commit
c15839da40
@ -1,3 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
compress: true,
|
||||||
};
|
};
|
||||||
|
@ -203,6 +203,9 @@ class Config(Base):
|
|||||||
# Timeout when launching the gunicorn server.
|
# Timeout when launching the gunicorn server.
|
||||||
timeout: int = constants.TIMEOUT
|
timeout: int = constants.TIMEOUT
|
||||||
|
|
||||||
|
# Whether to enable or disable nextJS gzip compression.
|
||||||
|
next_compression: bool = True
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize the config values.
|
"""Initialize the config values.
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ WEB_ASSETS_DIR = os.path.join(WEB_DIR, "public")
|
|||||||
TAILWIND_CONFIG = os.path.join(WEB_DIR, "tailwind.config.js")
|
TAILWIND_CONFIG = os.path.join(WEB_DIR, "tailwind.config.js")
|
||||||
# Default Tailwind content paths
|
# Default Tailwind content paths
|
||||||
TAILWIND_CONTENT = ["./pages/**/*.{js,ts,jsx,tsx}"]
|
TAILWIND_CONTENT = ["./pages/**/*.{js,ts,jsx,tsx}"]
|
||||||
|
# The NextJS config file
|
||||||
|
NEXT_CONFIG_FILE = "next.config.js"
|
||||||
# The sitemap config file.
|
# The sitemap config file.
|
||||||
SITEMAP_CONFIG_FILE = os.path.join(WEB_DIR, "next-sitemap.config.js")
|
SITEMAP_CONFIG_FILE = os.path.join(WEB_DIR, "next-sitemap.config.js")
|
||||||
# The node modules directory.
|
# The node modules directory.
|
||||||
|
@ -207,11 +207,24 @@ def initialize_app_directory(app_name: str, template: constants.Template):
|
|||||||
def initialize_web_directory():
|
def initialize_web_directory():
|
||||||
"""Initialize the web directory on reflex init."""
|
"""Initialize the web directory on reflex init."""
|
||||||
console.log("Initializing the web directory.")
|
console.log("Initializing the web directory.")
|
||||||
path_ops.rm(os.path.join(constants.WEB_TEMPLATE_DIR, constants.NODE_MODULES))
|
|
||||||
path_ops.rm(os.path.join(constants.WEB_TEMPLATE_DIR, constants.PACKAGE_LOCK))
|
|
||||||
path_ops.cp(constants.WEB_TEMPLATE_DIR, constants.WEB_DIR)
|
path_ops.cp(constants.WEB_TEMPLATE_DIR, constants.WEB_DIR)
|
||||||
path_ops.mkdir(constants.WEB_ASSETS_DIR)
|
path_ops.mkdir(constants.WEB_ASSETS_DIR)
|
||||||
|
|
||||||
|
# update nextJS config based on rxConfig
|
||||||
|
next_config_file = os.path.join(constants.WEB_DIR, constants.NEXT_CONFIG_FILE)
|
||||||
|
|
||||||
|
with open(next_config_file, "r") as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
if "compress:" in line:
|
||||||
|
new_line = line.replace(
|
||||||
|
"true", "true" if get_config().next_compression else "false"
|
||||||
|
)
|
||||||
|
lines[i] = new_line
|
||||||
|
|
||||||
|
with open(next_config_file, "w") as file:
|
||||||
|
file.writelines(lines)
|
||||||
|
|
||||||
# Write the current version of distributed reflex package to a REFLEX_JSON."""
|
# Write the current version of distributed reflex package to a REFLEX_JSON."""
|
||||||
with open(constants.REFLEX_JSON, "w") as f:
|
with open(constants.REFLEX_JSON, "w") as f:
|
||||||
reflex_json = {"version": constants.VERSION}
|
reflex_json = {"version": constants.VERSION}
|
||||||
|
Loading…
Reference in New Issue
Block a user