Skip to content

Instantly share code, notes, and snippets.

@r17x
Created January 15, 2019 16:51
Show Gist options
  • Select an option

  • Save r17x/9d2b404ac39dba9561bb6916cc0c3889 to your computer and use it in GitHub Desktop.

Select an option

Save r17x/9d2b404ac39dba9561bb6916cc0c3889 to your computer and use it in GitHub Desktop.
Looping Assets in Create-react-app

an Example Looping Assets like CSS, JS & Font in Create-React-App

  • cra-project/public/index.html
    <% for ( var css in htmlWebpackPlugin.files.css ) { %>
        <link rel="preload" as="style" href="<%=htmlWebpackPlugin.files.css[css]%>" as="style" onload='this.rel="stylesheet"'>
    <% } %>
    <% for ( var js in htmlWebpackPlugin.files.js ) { %>
        <link rel="preload" as="script" href="<%=htmlWebpackPlugin.files.js[js] %>" as="script">
    <% } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment