How to use guess-webpack - 6 common examples

To help you get started, we’ve selected a few guess-webpack 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 daliborgogic / guess-module / lib / templates / plugin.js View on Github external
Vue.nextTick(() => {
        // console.log('Keys ', Object.keys(guess()))
        const predictions = Object.keys(guess()).sort((a, b) => a.probability - b.probability)
        // console.log('Predictions ', predictions)
        predictions.forEach(path => {
          // console.log('Path: ', path)
          router.getMatchedComponents(path).forEach(Component => {
            if (typeof Component === 'function' && !Component.__prefetched) {
              try {
                Component()
                Component.__prefetched = true
              } catch (e) {}
            }
          })
        })
      })
    }
github guess-js / gatsby-guess / src / templates / article.js View on Github external
render() {
    // eslint-disable-next-line
    const matches = guess({ path: this.props.location.pathname })
    Object.keys(matches).forEach(match => fetchArticle(match.slice(6)))
    let toRender = ``
    const articleName = this.props.location.pathname.slice(6)
    if (this.props.location.pathname === `/_/`) {
      return <div>hi</div>
    }
    if (this.props.data.wikipediaArticle) {
      toRender = this.props.data.wikipediaArticle.rendered
    } else if (htmlCache[articleName]) {
      toRender = htmlCache[articleName]
    } else if (
      !this.props.data.wikipediaArticle &amp;&amp;
      !promiseCache[articleName]
    ) {
      // eslint-disable-next-line
      fetchArticle(articleName).then(text =&gt; {
github guess-js / gatsby-guess / plugins / gatsby-guess-js-link-highlight / gatsby-browser.js View on Github external
const colorLinks = () =&gt; {
  const guesses = guess({
    path: window.location.pathname
  });
  [].slice.call(document.querySelectorAll(`a`)).forEach(n =&gt; n.classList.add('prefetch-priority-0'));
  let all = Object.keys(guesses).map(key =&gt; guesses[key]);
  all = all.filter((p, idx) =&gt; all.indexOf(p) === idx); //.sort((a, b) =&gt; a - b);
  Object.keys(guesses).forEach(c =&gt; {
    const probability = guesses[c];
    let totalBigger = 0;
    for (let i = 0; i &lt; all.length; i += 1) {
      if (all[i] &gt; probability) {
        totalBigger += 1;
      }
    }
    const third = Math.round(all.length / 3);
    let color = 1;
    if (totalBigger &lt; third) {
github mgechev / guess-next / components / layout.js View on Github external
const layout = ({ router, children, title = 'đź”® Next.js + Guess.js' }) =&gt; {
  let predictions = [];
  if (typeof window !== 'undefined') {
    predictions = Object.keys(guess()).sort((a, b) =&gt; a.length - b.length);
    predictions.forEach(p =&gt; router.prefetch(p));
  }

  return (
    <div>
      
        <title>{title}</title>
        
        
        
        
        
      
      <header>
        <nav>
          <span></span></nav></header></div>
github mgechev / guess-next / next.config.js View on Github external
webpack: function(config, { isServer }) {
    if (isServer) return config;
    config.plugins.push(
      new GuessPlugin({
        debug: true,
        reportProvider() {
          return Promise.resolve(JSON.parse(require('fs').readFileSync('./routes.json')));
        },
        runtime: {
          delegate: true
        }
      })
    );
    return config;
  }
};
github daliborgogic / guess-module / lib / module.js View on Github external
this.extendBuild((config, ctx) => {
    if (!ctx.isDev && ctx.isClient) {
      config.plugins.push(new GuessPlugin(options))
    }
  })
}

guess-webpack

Webpack plugins for the Machine Learning-driven bundler

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular guess-webpack functions