Skip to content

Instantly share code, notes, and snippets.

@ADCDS
Forked from obonyojimmy/jquery-datatables-webpack
Created March 25, 2017 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ADCDS/b0296063a4f8be3cfe4bd33bbba7b516 to your computer and use it in GitHub Desktop.
Save ADCDS/b0296063a4f8be3cfe4bd33bbba7b516 to your computer and use it in GitHub Desktop.
DataTables.net with webpack
Here's how to make jQuery DataTables work with npm and webpack. This is the simplest way I found to do it.
See the previous revision of this gist for a way to do it with forcing AMD to be disabled if you need that.
Install DT core: npm install datatables.net
Install a DT style: npm install datatables.net-dt
Then to initialize DT in your app, do this in your main entry point:
// you can use import or require
import dt from 'datatables.net';
import 'datatables.net-dt/css/jquery.datatables.css';
Now you can use .DataTable():
$('table[data-table]').DataTable(); // or whatever you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment