Datatable in Symfony 5.15 and webpack
Datatable in Symfony 5.15 and webpack
Hello everyone, I tried to install Datatable put I can't make it work, I use npm commands.
package.json
"datatables.net": "^1.10.21",
"datatables.net-bs4": "^1.10.21",
"datatables.net-responsive-bs4": "^2.2.5",
"imports-loader": "^1.1.0",
"jquery": "^3.5.1",
"webpack-notifier": "^1.6.0"
In webpack, I follow this gist https://gist.github.com/jrunestone/2fbe5d6d5e425b7c046168b6d6e74e95#file-jquery-datatables-webpack
In my console, I got this message:
Uncaught Error: Module build failed (from ./node_modules/imports-loader/dist/cjs.js):
ValidationError: Invalid options object. Imports Loader has been initialized using an options object that does not match the API schema.
- options should be one of these:
object { imports, … } | object { wrapper, … } | object { additionalCode, … }
Details:
* options has an unknown property 'define'. These properties are valid:
object { imports, … } | object { wrapper, … } | object { additionalCode, … }
* options misses the property 'imports' | should be any non-object.
* options misses the property 'wrapper' | should be any non-object.
* options misses the property 'additionalCode' | should be any non-object.
at validate (...\node_modules\schema-utils\dist\validate.js:98:11)
at Object.loader (...\node_modules\imports-loader\dist\index.js:28:28)
Thank you for your help.
Answers
Problem solved. I get rid of the addLoader in webpack config and remove the ($) in the app.js.
I have the same problem, but I can't just solve it by removing addLoader and ($), because I get TypeError: DataTable is undefined. Does anyone have any updates on this issue?
@MotAtlas Are you seeing the exact same error?
Colin