Search code examples
webpackjspdfjspdf-autotable

How to register jsPDF-AutoTable plugin with jsPDF in webpack?


I've created a vendor module according to UMD and set jsPDF as a dependency. How do I achieve, that jsPDF-AutoTable plugin will be registered with jsPDF before injecting jsPDF into my vendor module?

I've already solved jsPDF is not defined using ProvidePlugin in my webpack.config.js file like this:

config.plugins = [
    new webpack.ProvidePlugin({
        jsPDF: 'jspdf'
    })
]

Solution

  • There is an example how to use webpack in the jspdf autotable repository. Basically you simply need to require the plugin after jspdf.

    var jsPDF = require('jspdf');
    require('jspdf-autotable');
    

    You shouldn't need to use the provider plugin with the latest version of jspdf.