How can I add Critters after HtmlWebpackPlugin?

derevandal
50
derevandal
commented a year ago

Hi, I'm trying add Critters in my nuxt.config.js but, because of some bug, I need insert after HtmlWebpackPlugin.

I tried and failed with this:

build: {
...
   extend(config, ctx) {
      const HtmlWebpackPlugin = config.plugins.find(plugin => {
        return plugin.constructor.name === 'HtmlWebpackPlugin'
      })
      const HtmlWebpackPluginIndex =
        config.plugins.indexOf(HtmlWebpackPlugin) + 1

      config.plugins.splice(
        HtmlWebpackPluginIndex,
        0,
        new Critters({
          preload: 'swap',
          preloadFonts: true,
          noscriptFallback: true
        })
      )
   }

   ..
}

Could anyone help me?

Thanks

0
Informations
Question โ€ข Unresolved
#c7991 - Created a year ago