Hello! It is possible in index.html to include some content based on NODE_ENV ?
For example when I am in production I want to include Google Analytics, or other services scripts.
Thanks!
I think we might accidentally support ejs there although it wasn鈥檛 really intentional 馃槢 Let me know if you can make it work somehow.
In general though I find it might be easier to set this up from JS by appending script tags.
@gaearon LOL, it works, great! Thanks!
added this in head tag
<% if (process.env.NODE_ENV === 'production') { %>
<script>
// my GA script
</script>
<% } %>
I also wanted to include a partial, but it seems is not ejs
By default HtmlWebpackPlugin uses lodash template loader that does not support include
https://lodash.com/docs#template
By default (if you don't specify any loader in any way) a fallback lodash loader kicks in.
https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md
My use case. I want to import inline svg for icons. Did this steps
npm install ejs-compiled-loaderHtmlWebpackPlugin tonew HtmlWebpackPlugin({
inject: true,
template: `!!ejs-compiled-loader!${paths.appHtml}`,
}),
public/index.html include any partialspublic/icons.svg content in final index.htmlAny chance to add this to CRA?
I can make a PR.
Thanks!
@gaearon
@iamandrewluca ,Has your suggestion been accepted?
Din't make any PR at that time, and was left behind.
Now I import SVG's in react using react-scripts@2.*
https://facebook.github.io/create-react-app/docs/adding-images-fonts-and-files#adding-svgs
Most helpful comment
@gaearon LOL, it works, great! Thanks!
added this in
headtag