Sha256: 4da5a102d78cc3026b8fcb16632ab4e0cd6bc05fd9bce6e7615bac14ef3d7eb4

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

### Webpack

We assume here that Bootstrap and FontAwesome are already installed with Webpack.

Inspired by https://datatables.net/download and completed :

Add npm packages :
```sh
$ yarn add imports-loader
```
```sh
$ yarn add datatables.net
$ yarn add datatables.net-bs
$ yarn add datatables.net-buttons
$ yarn add datatables.net-buttons-bs
$ yarn add datatables.net-responsive
$ yarn add datatables.net-responsive-bs
$ yarn add datatables.net-select
$ yarn add datatables.net-select-bs
```

In `config/webpack/loaders/datatables.js` :

```js
module.exports = {
  test: /datatables\.net.*/,
  loader: 'imports-loader?define=>false'
}
```

In `config/webpack/environment.js` :

```js
const { environment } = require('@rails/webpacker')
const datatables = require('./loaders/datatables')
environment.loaders.append('datatables', datatables)
module.exports = environment
```

in `app/javascript/pack/application.js` :

```js
// Load Datatables
require('datatables.net-bs')(window, $)
require('datatables.net-buttons-bs')(window, $)
require('datatables.net-buttons/js/buttons.colVis.js')(window, $)
require('datatables.net-buttons/js/buttons.html5.js')(window, $)
require('datatables.net-buttons/js/buttons.print.js')(window, $)
require('datatables.net-responsive-bs')(window, $)
require('datatables.net-select')(window, $)
// require('yadcf')(window, $) // Uncomment if you use yadcf (need a recent version of yadcf)
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ajax-datatables-rails-1.2.0 doc/webpack.md
ajax-datatables-rails-1.1.0 doc/webpack.md