Timkor / nuxt-polyfill

Ease adding polyfills to your Nuxt.js project
MIT License
97 stars 1 forks source link

A demo of a local file would be good #5

Open weotch opened 5 years ago

weotch commented 5 years ago

I was getting these errors:

friendly-errors 15:42:24  ERROR  Failed to compile with 1 errors
friendly-errors 15:42:24 This relative module was not found:
friendly-errors 15:42:24 
friendly-errors 15:42:24 * ./vendor/polyfills/nodelist-foreach.js in ./.nuxt/nuxt-polyfill/vendor/polyfills/nodelist-foreach.js.js

Until I changed this:

  polyfill: {
    features: [
      {
        require: "vendor/polyfills/nodelist-foreach",
        detect: function() {
          return window.NodeList && !NodeList.prototype.forEach;
        }
      }
    ]
  }

To:

  polyfill: {
    features: [
      {
        require: `${__dirname}/vendor/polyfills/nodelist-foreach`,
        detect: function() {
          return window.NodeList && !NodeList.prototype.forEach;
        }
      }
    ]
  }

Not sure if that's the best way though and an example might help others

lucastraba commented 3 years ago

@Timkor, this is not working for me, either. It would be very nice to have an example of how to use this with custom polyfills.