How do I pack javascript for the acp/ a widget into a single js file?

Solved Plugin Development
  • I'm working on fixing the twitch monitor plugin, and so far I got the admin control panel working. My problem is that all the code for the acp is on the folder public/js/acp.js, so I edited that one. But I realized that the code is also on the client/acp folder, and I guess there must be some sort of build process to pack all that folder into a single javascript file. The same thing happens with the widget folder in cient/widget.

    I checked to docs and I didn't find anything like that on the plugin documentation, does anyone know what the author could have used to produce those .js files?

  • @v_risalab i figured it out. The acp code uses browserify and the widget code uses webpack!

Suggested Topics

  • 0 Votes
    1 Posts


    How to require local utilities in my acpScript properly? I want to separate functions in my acpScript of my plugin into several JS files. My acpScipt is located at path public/lib/admin/index.js with codes:

    'use strict'; /* globals socket, define, require */ define( 'admin/plugins/myPlugin', [ 'myAdminUtilities' ], function (util) { const Admin = {}; Admin.init = function () { socket.emit( 'plugins.myPlugin.getData', myAdminUtilities.handleResponse, ); }; return Admin; } );

    Then, file myAdminUtilities is located at path public/lib/admin/utils.js with codes:

    define('admin/plugins/myAdminUtilities', function () { const adminUtils = {}; adminUtils.handleResponse = function (error, data) { // process data ... }; return adminUtils; });

    Also, I have modified my plugin.json with following:

    { ... "modules": { "myAdminUtilities": "public/lib/admin/utils.js" }, ... }

    But, I get get admin/plugins/myAdminUtilities (404 Not found) every time I enter my plugin ACP page. What's the proper way to reach my goal?

  • 0 Votes
    1 Posts

    Suppose there are two files.

    library.js in the /nodebb-plugin-namePlugin
    file.js in /nodebb-plugin-namePlugin/static/lib

    Now I must do a lot of operation in my library.js and I must check when user is created. So I use the hook and It's everything ok, but, after I must my check in library I need to send a message to my file.js to change background color of a component. The proble is that I used this to communicate:

    websockets = module.parent.require('./'), //library.js'uid_' + data.uid).emit('hash', { 'username': }); //file.js socket.on('hash',function(){ console.log("DOG); });

    The problem is that I don't have data.uid value because I'm checking before that an user can registrate himself. Anyone can help me to use websocket without uid or can suggest me other methods?

  • 1 Votes
    9 Posts

    @nicolas search for theme exodus.its persona fork with widgets, it not finished but it can help you to see the code

  • 1 Votes
    11 Posts

    I did a try and i liked it 🙂

    It would be awesome if you could choose what category works that way and what category works on the standard forum way 🙂

  • 0 Votes
    9 Posts

    Cool! Just signed it.