Skip to content

Instantly share code, notes, and snippets.

@lifeisfoo
Created May 13, 2022 08:05
Show Gist options
  • Save lifeisfoo/d27b93a00e6a536221fdd90c6936405d to your computer and use it in GitHub Desktop.
Save lifeisfoo/d27b93a00e6a536221fdd90c6936405d to your computer and use it in GitHub Desktop.
interpolate-html-plugin

public/index.html


<link href="%PUBLIC_URL%/assets/favicon-32x32.png" />

// OR

<script>
window.__PUBLIC_URL__ = "%PUBLIC_URL%";
</script>

webpack

https://www.npmjs.com/package/interpolate-html-plugin

const interpolateHtmlPlugin = webpackConfig.plugins.find(
  (p) => p.constructor.name === 'InterpolateHtmlPlugin'
)
interpolateHtmlPlugin.replacements.PUBLIC_URL = process.env.PUBLIC_URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment