jiboulex
jiboulex

Reputation: 3021

Webpack, datatable & yadcf

I'm trying to switch from a requirejs config to a webpack one and am having trouble to make yadcf work.

In my packages.json :

{
  ...
  "dependencies": {
    ...
    "datatables.net": "^1.10.12",
    "datatables.net-bs": "^1.10.12",
    "jquery": "^3.1.1",
    "yadcf-npm": "^0.8.9"
  }
}

My webpack.config.js :

...
resolve: {
  alias: {
    ...
    datatables: path.join(__dirname, 'node_modules/datatables.net/js/jquery.dataTables'),
    datatablesBootstrap: path.join(__dirname, 'node_modules/datatables.net-bs/js/dataTables.bootstrap'),
    yadcf: path.join(__dirname, 'node_modules/yadcf-npm/jquery.dataTables.yadcf.js'),
  }
}

my script :

define(['jquery', 'datatablesBootstrap', 'yadcf'], function($) {
    $(document).ready(function(){
        ...
        var myDatatable = dataTable = $('#elem').DataTable({
            ...
        });

        myDatatable.yadcf([
            ...
        ]);
    });
});

I keep having the same issue where yadcf is not defined

Uncaught ReferenceError: yadcf is not defined(…)

Do you know what I'm missing here ?

Upvotes: 1

Views: 269

Answers (1)

Daniel
Daniel

Reputation: 37061

You should use yadcf v0.9.1 , since the support for AMD / CommonJS was added in this release and it should work with Webpack too, you can get it from npm or from github or bower...

Upvotes: 2

Related Questions