I totaly don’t understand why !
command :
npm run build
package.json :
{
"name": "gestion",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack ./src/js/app.js --output-filename=../js/bundle.js --mode=development"
},
"devDependencies": {
"jquery": "^3.5.1",
"webpack": "^5.1.3",
"webpack-cli": "^4.0.0"
}
}
src/js/main.js
var baseUrl = OC.generateUrl('/apps/gestion');
$(document).ready( function () {
$.ajax({
url: baseUrl+'/getClients',
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
$.each(JSON.parse(response), function(arrayID, myresp) {
$('#client').DataTable().row.add([myresp.id,
myresp.entreprise,
myresp.nom,
myresp.prenom,
myresp.siret,
myresp.telephone,
myresp.mail,
myresp.adresse]);
//$('#client').DataTable().row.add(myresp);
});
$('#client').DataTable().draw(false);
}).fail(function (response, code) {
console.log(code);
});
} );
src/js/app.js
window.$ = require('jquery');
require('./main.js');
js/bundle.js OK !
templates/index.php
<?php
style('gestion', ['style','datatables.min']);
script('gestion', ['bundle']);
?>
<div id="app">
<div id="app-navigation">
<?php print_unescaped($this->inc('navigation/index')); ?>
<?php print_unescaped($this->inc('settings/index')); ?>
</div>
<div id="app-content">
<div id="app-content-wrapper">
<?php print_unescaped($this->inc('content/index')); ?>
</div>
</div>
</div>