harlan-zw / nuxt-webpack-optimisations

Make your Nuxt.js webpack builds faster ⚡
271 stars 8 forks source link

Documentation is ambiguous / unclear on certain aspects #40

Closed juni0r closed 2 years ago

juni0r commented 2 years ago

Hi,

I'm a bit at loss concerning the module configuration. Maybe you can you provide a more exhaustive example config to demonstrate various options and how to use them exactly.

I'm not intimately familiar with esbuild, so I can only take guesses on how to specify more granular options. Specifically, I would like to disable esbuild's minifyIdentifiers and I have no clue how to do this after reading the docs.

If you could shed some light on the topic, It'd be greatly appreciated.

Features

There are two different examples for configuration:

webpackOptimisations: {
  // hard source is the riskiest, if you have issues don't enable it
  hardSourcePlugin: process.env.NODE_ENV === 'development',
  parallelPlugin: process.env.NODE_ENV === 'development',
}

and also

webpackOptimisations: {
  features: {
    // Note: just an example of keys, these are all keys and their default
    hardSourcePlugin: false,
    parallelPlugin: false,
  }
}

So are features configured top-level or nested under features?

Esbuild config

On configuring esbuildMinifyOptions, the documentation just says

export default {
  client: {
    target: 'es2015',
  },
  server: {
    target: 'node14',
  },
  modern: {
    target: 'es2015',
  },
}

export default like what? From where? client, server? Huh?! Wouldn't this go into webpackOptimisations in nuxt.config.js, like so:

webpackOptimisations: {
  esbuildMinifyOptions: {
    // ...
  }
}

Thanks!

harlan-zw commented 2 years ago

Hey @juni0r

Thanks for bringing this up and sorry for the slow response. You are right, the documentation was not clear.

I've made an effort to try and improve that, I've specifically added a section to the docs for Modifying Esbuild Behaviour to help other users trying to do the same thing.

Let me know if you think it needs more work