<h2 dir="auto">Feature request</h2>





<p dir="auto"><strong>What is the expected behavior?</strong><br>
The <code class="notranslate">cache.maxGenerations</code> config works in <code class="notranslate">filesystem</code> cache to keep cache files slim.</p>
<p dir="auto"><strong>What is motivation or use case for adding/changing the behavior?</strong><br>
Our project is huge, which generate a huge .cache directory over 800MB, and the cache size keep increasing with the passes of compilation. We run the CI progress in a new docker environment everytime when the project code changed, so we need store the .cache directory in outside storage, huge cache file will slow down the CI progress obviously.</p>
<p dir="auto">I read the source code and find that filesystem cache always keep the unused items until the maxAge is exceeded, so what i need is to set maxGenerations limit to 1 and remove unused items from cache files everytime.</p>
<p dir="auto"><strong>How should this be implemented in your opinion?</strong><br>
Record the generations in pack content items, read the <code class="notranslate">cache.maxGenerations</code> config and decide to keep or remove unused items in <code class="notranslate">Pack._optimizeUnusedContent</code>.</p>
<p dir="auto"><strong>Are you willing to work on this yourself?</strong><br>
Yes</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
I need to set the max chunck to only 1 and I can't currently do that. This error has been reported before but nothing was done.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">1 - Create a Nuxt App using <code class="notranslate">npx create-nuxt-app &lt;project-name&gt;</code> (Choose bootstrap, axios and eslint when asked)<br>
2 - Change your "nuxt.config.js" to match the one below.<br>
3 - <code class="notranslate">npm run build</code><br>
4 - Verify that is a Webpack Bug</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/55927613/106352939-cdcda400-62de-11eb-808d-d0eda77abe6f.png"><img src="https://user-images.githubusercontent.com/55927613/106352939-cdcda400-62de-11eb-808d-d0eda77abe6f.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">5 - Change <code class="notranslate">maxCount:4</code><br>
6 - <code class="notranslate">npm run build</code><br>
7 - Verify that it now worked</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/55927613/106353072-d4a8e680-62df-11eb-865b-f394e04b9142.png"><img src="https://user-images.githubusercontent.com/55927613/106353072-d4a8e680-62df-11eb-865b-f394e04b9142.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">obs: The file is located in the root of the project.<br>
nuxt.config.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import webpack from 'webpack';

export default {
  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',
  ssr: false,

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'salesforce-query-editor',
    htmlAttrs: {
      lang: 'en',
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    link: [],
    script: [],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    ['@nuxtjs/eslint-module', { fix: true, quiet: true }],
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    'bootstrap-vue/nuxt',
    '@nuxtjs/axios',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {},

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    extend(config, ctx) {
      if (ctx.isDev) {
        config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map';
      }
    },

    plugins: [
      new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 1
      })
    ],
  },

  router: {
    mode: 'hash',
  },
}
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">webpack</span> <span class="pl-k">from</span> <span class="pl-s">'webpack'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-kos">{</span>
  <span class="pl-c">// Target: https://go.nuxtjs.dev/config-target</span>
  <span class="pl-c1">target</span>: <span class="pl-s">'static'</span><span class="pl-kos">,</span>
  <span class="pl-c1">ssr</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>

  <span class="pl-c">// Global page headers: https://go.nuxtjs.dev/config-head</span>
  <span class="pl-c1">head</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">title</span>: <span class="pl-s">'salesforce-query-editor'</span><span class="pl-kos">,</span>
    <span class="pl-c1">htmlAttrs</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">lang</span>: <span class="pl-s">'en'</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">meta</span>: <span class="pl-kos">[</span>
      <span class="pl-kos">{</span> <span class="pl-c1">charset</span>: <span class="pl-s">'utf-8'</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span> <span class="pl-c1">name</span>: <span class="pl-s">'viewport'</span><span class="pl-kos">,</span> <span class="pl-c1">content</span>: <span class="pl-s">'width=device-width, initial-scale=1'</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span> <span class="pl-c1">hid</span>: <span class="pl-s">'description'</span><span class="pl-kos">,</span> <span class="pl-c1">name</span>: <span class="pl-s">'description'</span><span class="pl-kos">,</span> <span class="pl-c1">content</span>: <span class="pl-s">''</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-c1">link</span>: <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-c1">script</span>: <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>

  <span class="pl-c">// Global CSS: https://go.nuxtjs.dev/config-css</span>
  <span class="pl-c1">css</span>: <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span>

  <span class="pl-c">// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins</span>
  <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span>

  <span class="pl-c">// Auto import components: https://go.nuxtjs.dev/config-components</span>
  <span class="pl-c1">components</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>

  <span class="pl-c">// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules</span>
  <span class="pl-c1">buildModules</span>: <span class="pl-kos">[</span>
    <span class="pl-c">// https://go.nuxtjs.dev/eslint</span>
    <span class="pl-kos">[</span><span class="pl-s">'@nuxtjs/eslint-module'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">fix</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span> <span class="pl-c1">quiet</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>

  <span class="pl-c">// Modules: https://go.nuxtjs.dev/config-modules</span>
  <span class="pl-c1">modules</span>: <span class="pl-kos">[</span>
    <span class="pl-s">'bootstrap-vue/nuxt'</span><span class="pl-kos">,</span>
    <span class="pl-s">'@nuxtjs/axios'</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>

  <span class="pl-c">// Axios module configuration: https://go.nuxtjs.dev/config-axios</span>
  <span class="pl-c1">axios</span>: <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span>

  <span class="pl-c">// Build Configuration: https://go.nuxtjs.dev/config-build</span>
  <span class="pl-c1">build</span>: <span class="pl-kos">{</span>
    <span class="pl-en">extend</span><span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">,</span> <span class="pl-s1">ctx</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">ctx</span><span class="pl-kos">.</span><span class="pl-c1">isDev</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">devtool</span> <span class="pl-c1">=</span> <span class="pl-s1">ctx</span><span class="pl-kos">.</span><span class="pl-c1">isClient</span> ? <span class="pl-s">'source-map'</span> : <span class="pl-s">'inline-source-map'</span><span class="pl-kos">;</span>
      <span class="pl-kos">}</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>

    <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span>
      <span class="pl-k">new</span> <span class="pl-s1">webpack</span><span class="pl-kos">.</span><span class="pl-c1">optimize</span><span class="pl-kos">.</span><span class="pl-c1">LimitChunkCountPlugin</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
        <span class="pl-c1">maxChunks</span>: <span class="pl-c1">1</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>

  <span class="pl-c1">router</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">mode</span>: <span class="pl-s">'hash'</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span></pre></div>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
It should output one js file as I specified maxChunk = 1 on the LimitChunkCountPlugin</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4<br>
Node.js version: v12.13.0<br>
Operating System:  Windows<br>
Additional tools:</p>