Silex
Silex copied to clipboard
Silex Desktop Publish Files into same directory rather than JS and CSS Folders
Is there a way to tell Silex to publish all the files into one directory? My use case is a bit different to most and I'm building web interfaces for an Arduino ESP32 Microcontroller which uses flash memory but does not support directories, it is a flat-file system.
At the moment I have to copy every out of the js and css folder and paste it into the same directory as the .html file, I then edit the html file to use the directory for the js and css files. So every time I make a change in the editor and publish it, I have to repeat the process which becomes quite time consuming
Hi @MatthewReed303 Interesting use case, is it for a diy project? Yes there is a way, it takes a little bit of nodejs, do you have the basics of programming in node?
Hi @lexoyo, Yes for a few wireless projects around the farm, but will expand on it in the future. It's pretty straightforward and just uses WebSocket for the data transfer. Have no experience in node.js in the process of learning a bit of JavaScript so can add node.js in there also if you put me in the right direction.
I have to also add this to the top of the JavaScript file when using the code tab in the editor $(document).ready(function()
otherwise I get errors with linking to HTML elements. I can also add defer to the JavaScript source file in the HTML file to fix this issue.
Hi @MatthewReed303 Is this still needed? Should I give you some pointers?
Hi @lexoyo, yes that would be great as I'm still have to manually move files etc So having option to output everything in the one directory would be great. Thanks
Hello
You will need to create a custom hosting provider to change the folders when publishing
- Here is an example of a hosting provider https://github.com/lexoyo/silex-for-hosting-company/blob/master/custom-provider.js
- In your case you will not need to override getVhosts, finalizePublication, and so on, instead override getJsFolder, getHtmlFolder getAssetsFolder and getCssFolder
- Here is a list of everything you can override https://github.com/silexlabs/Silex/blob/99323822de956ec0c6e761570bffe2c02dfaaf0c/src/ts/server/types.ts#L10
In order to use this custom hosting provider, you need to host your instance of silex first https://github.com/silexlabs/Silex/wiki/How-to-Host-An-Instance-of-Silex
Hi @MatthewReed303 Did you have a look at the links?
Hi lexoyo, sorry I missed the reply. will take a look now. Thanks
👍 🙇