{%- set rendered_chunks = [] -%} {%- set css_links = [] -%} {%- set js_scripts = [] -%} {%- macro collect_assets(chunk_name, level=0) -%} {% if chunk_name not in rendered_chunks %} {% set _ = rendered_chunks.append(chunk_name) %} {% set chunk = manifest[chunk_name] %} {% if chunk.css %} {% for css_file in chunk.css %} {% if css_file not in css_links %} {% set _ = css_links.append((basename, css_file)) %} {% endif %} {% endfor %} {% endif %} {% if chunk.imports %} {% for import in chunk.imports %} {% set _ = collect_assets(import, level + 1) %} {% endfor %} {% endif %} {% if chunk.file.endswith('.js') %} {% if chunk.file not in js_scripts %} {% set _ = js_scripts.append((basename, chunk.file, level == 0)) %} {% endif %} {% elif chunk.file.endswith('.css') %} {% if chunk.file not in css_links %} {% set _ = css_links.append((basename, chunk.file)) %} {% endif %} {% endif %} {% endif %} {%- endmacro -%} {%- macro render_css() -%} {%- for basename, css_file in css_links -%} {% endfor -%} {%- endmacro -%} {%- macro render_js() -%} {%- for basename, js_file, is_entry in js_scripts -%} {%- if is_entry -%} {% else -%} {% endif -%} {%- endfor -%} {%- endmacro -%} Phoenix {% if not is_development -%} {% set _ = collect_assets('index.tsx') -%} {{- render_css() -}} {%- endif -%}
{% if is_development -%} {%- else -%} {{- render_js() -}} {%- endif -%}