How to use the html-webpack-plugin/lib/chunksorter.auto function in html-webpack-plugin

To help you get started, we’ve selected a few html-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-cli / packages / @vue / cli-service / lib / config / app.js View on Github external
chunks: 'initial',
              reuseExistingChunk: true
            }
          }
        })
    }

    // HTML plugin
    const resolveClientEnv = require('../util/resolveClientEnv')

    // #1669 html-webpack-plugin's default sort uses toposort which cannot
    // handle cyclic deps in certain cases. Monkey patch it to handle the case
    // before we can upgrade to its 4.0 version (incompatible with preload atm)
    const chunkSorters = require('html-webpack-plugin/lib/chunksorter')
    const depSort = chunkSorters.dependency
    chunkSorters.auto = chunkSorters.dependency = (chunks, ...args) => {
      try {
        return depSort(chunks, ...args)
      } catch (e) {
        // fallback to a manual sort if that happens...
        return chunks.sort((a, b) => {
          // make sure user entry is loaded last so user CSS can override
          // vendor CSS
          if (a.id === 'app') {
            return 1
          } else if (b.id === 'app') {
            return -1
          } else if (a.entry !== b.entry) {
            return b.entry ? -1 : 1
          }
          return 0
        })
github ksky521 / nodeppt / packages / nodeppt-serve / config / app.js View on Github external
minChunks: 2,
                        priority: -20,
                        chunks: 'initial',
                        reuseExistingChunk: true
                    }
                }
            });
        }

        // HTML plugin
        // #1669 html-webpack-plugin's default sort uses toposort which cannot
        // handle cyclic deps in certain cases. Monkey patch it to handle the case
        // before we can upgrade to its 4.0 version (incompatible with preload atm)
        const chunkSorters = require('html-webpack-plugin/lib/chunksorter');
        const depSort = chunkSorters.dependency;
        chunkSorters.auto = chunkSorters.dependency = (chunks, ...args) => {
            try {
                return depSort(chunks, ...args);
            } catch (e) {
                // fallback to a manual sort if that happens...
                return chunks.sort((a, b) => {
                    // make sure user entry is loaded last so user CSS can override
                    // vendor CSS
                    if (a.id === 'app') {
                        return 1;
                    } else if (b.id === 'app') {
                        return -1;
                    } else if (a.entry !== b.entry) {
                        return b.entry ? -1 : 1;
                    }
                    return 0;
                });