How to modify JS files of Nextcloud server

Hello,

I would like to make modifications to the Nextcloud server code, but this is my first time working with minified code. Should I apply my changes directly to these files? Are there source files (more readable) that would help me better understand the JavaScript of the application and make the necessary modifications?

Here are some of the affected files:

  • dist/files-search.js
  • dist/core-unified-search.js
  • dist/core-common.js

Thanks for your help!

Hello,

of course the devs do not work on minified code! The named files are part of the server package. To find the corresponding resources, you can look at the webpack config. For example, the dist/files-search.js is configured in this line.

After the coding, you (or anyone) can use NPM to run npm run build (or similar) to create the minified (or non-minified) packs as you already saw.

Christian

2 Likes

Super, thanks!

Do you know if these webpack configs are also linked to the stable version of the Nextcloud server?

For example, I am working on version 29 (stable version) and I want to make changes to the JavaScript which is in dist/ folder. How can I do that? I noticed that when downloading the stable versions, they do not countain the same folders as the master version available on GitHub.

For instance, the src/ directories are missing.

Yeah, this is true. In the src folder, the JS sources are located. Once a release is made, these are bundled into chunks that are to be served to the browser. This adds some additional code about how to load other chunks etc. These chunks are then minified and stored under dist (for distribution). Additional libraries (like Vue) are embedded in these chunks, so these are self-contained.

A similar procedure is in place for PHP (composer uses the vendor path).

1 Like

Yeah, these are the webpack.*.js files in git.

1 Like