How to insert CSS and JS generated by Webpack inline?

My CSS and JS is generated by Webpack. Here is how it is being inserted on the page:

    {{ $stylesheet := .Site.Data.webpack.main }}
    {{ with $stylesheet.css }}
      <link href="{{ relURL . }}" rel="stylesheet">
    {{ end }}
    {{ $script := .Site.Data.webpack.main }}
    {{ with $script.js }}
      <script src="{{ relURL . }}"></script>
    {{ end }}

Is there a way to insert CSS and JS inline?

Hi,

I cannot test your setup, but this is what I do:

{{- $CSS := resources.Get "css/main.css" | postCSS (dict "use" "autoprefixer") | minify }}
<style>{{ $CSS.Content | safeCSS }}</style>

You can skip the postCSS part.