title: HtmlWebpackPlugin not minifying script tag
body: <p>I'm using <a href="https://www.npmjs.com/package/html-webpack-plugin" rel="nofollow noreferrer">HtmlWebpackPlugin</a> with these settings:</p>
  
  <pre class="lang-js prettyprint-override"><code>new HtmlWebpackPlugin({
      template: 'src/index.ejs',
      minify: isDevelopment ? false : {
          caseSensitive: false,
          removeComments: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true,
          useShortDoctype: false,
          removeEmptyAttributes: true,
          removeStyleLinkTypeAttributes: true,
          removeScriptTypeAttributes: true,
          keepClosingSlash: false,
          minifyJS: true,
          minifyCSS: true,
          minifyURLs: true,
          sortAttributes: true,
          sortClassName: true,
      },
  }),
  </code></pre>
  
  <p>which I believe are forwarded to <a href="https://github.com/DanielRuf/html-minifier-terser" rel="nofollow noreferrer">html-minifier-terser</a>, but it's not compressing my <code>&lt;script&gt;</code> tag.</p>
  
  <p>The HTML and CSS are compacted, but not my JS. </p>
  
  <p>How can I enable script compression?</p>
  
  <hr>
  
  <p>Not completely true actually, I'm not sure what it's doing. This:</p>
  
  <pre class="lang-html prettyprint-override"><code>    &lt;script&gt;
          // TODO: compress this or move this or something
          if('serviceWorker' in navigator) {
              window.addEventListener('load', () =&gt; {
                  // https://github.com/GoogleChrome/workbox/issues/1790
                  navigator.serviceWorker.register('/service-worker.js').then(registration =&gt; {
                      console.info('SW registered: ', registration);
                  }).catch(registrationError =&gt; {
                      console.error('SW registration failed: ', registrationError);
                  });
              });
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>"Compresses" to this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;// TODO: compress this or move this or something
          if('serviceWorker' in navigator) {
              window.addEventListener('load', () =&gt; {
                  // https://github.com/GoogleChrome/workbox/issues/1790
                  navigator.serviceWorker.register('/service-worker.js').then(registration =&gt; {
                      console.info('SW registered: ', registration);
                  }).catch(registrationError =&gt; {
                      console.error('SW registration failed: ', registrationError);
                  });
              });
          }&lt;/script&gt;
  </code></pre>
  
  <p>i.e., it removed a little bit of whitespace, which might even just be from the <code>collapseWhitespace</code> option. However, this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;if('serviceWorker' in navigator)navigator.serviceWorker.register('/service-worker.js')&lt;/script&gt;
  </code></pre>
  
  <p>Will compress to:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;"serviceWorker"in navigator&amp;&amp;navigator.serviceWorker.register("/service-worker.js")&lt;/script&gt;
  </code></pre>
  
  <p>So it <em>is</em> doing something, but I don't know what. Does it not like when I have comments in there?</p>