Cannot enable jQuery datatables through webpack bower components

require('datatables'); does not work 

It's hard for me to try to include jQuery-Datatables as a bower webpack module, the current settings work with other bower components, here is part of the webpack configuration file:

 module.exports = { plugins: [ new webpack.ResolverPlugin( new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"]) ) ], resolve: { modulesDirectories: ['node_modules', 'bower_components'] } }; 
+5
source share
1 answer

The problem is that DirectoryDescriptionFilePlugin expects one string entry in the main field, and bower.json from datatables declares an array:

 "main": [ "media/js/jquery.dataTables.js", "media/css/jquery.dataTables.css" ] 

There is a whole discussion about why this is so here .

(shameless plugin)

I created a bower-webpack-plugin that you can look at. It is still under development, but must handle arrays in the main field. Also, if you find any problems with it, feel free to report an error and I will try to fix it.

+4
source

Source: https://habr.com/ru/post/1206027/


All Articles