DocPad slow on livereload and docpad server reloading every time - docpad

I'm fighting for some time with docpad performance in local development. Have issue with live reload. Small change in some less file takes even 100sec to regenerate and reload the server. It looks like even though there was a change in one file, he regenerates everything. I've added those, as suggested on docpad page:
watchOptions:
preferredMethods: ['watchFile','watch']
catchupDelay: 0
regenerateDelay: 0
also disabled tag plugin for local dev, as he is pretty nasty with its constant tags regeneration.
I'm on docpad 6.63.8 with the following plugins: coffeescript, eco, gulp, highlightjs, less, livereload, lunr, marked, paged, partials, tags, text
I thought that I will simply get over it with gulp watch, but obviously watch is not enough, server needs to be reloaded anyway and I don't think it is possible to replace livereload plugin with gulp livereload or I'm just to stupid to do this
I'm using text plugin a lot, and maybe it slows down?
I wanted to overcome the issue by using gulp for watching and regeneration and manual restart of the server and docpad server but I noticed that docpad server is regenerating all the files, even though they were already regenerated and are in the out dir.
Any ideas?

Yep - I've seen this problem with livereload. I see it especially with dynamic pages. To be honest I think the best solution for the moment is to just remove livereload - remove it from the package.json file and delete the livereload node_modules directory. To my mind, livereload is only saving you from having to hit the reload button on the browser.

Related

Jekyll not refreshing changes to custom CSS Subdirectory

For work I have to manage styles and keep them consistent between two different sites. To accomplish this, I created a repository where I can use gulp/scss to export the CSS I need. Changing this is not an available option for me.
One of the sites is built using Jekyll. I have cloned the CSS directory and pointed the CSS to pull from that directory, no problem. When I make changes to the scss, the gulp task exports the CSS, but the changes are reflected when I am running the site. It detects the changes and says it regenerates the file, but the CSS simply doesn't get updated. If I stop the Jekyll process and re-run bundle exec jekyll serve - the css changes immediately show up.
Basically, I just want to know if there is a way to make sure these files get updated. Any help would be greatly appreciated.

Can't save when running "jekyll serve" on Windows 8.1, Notepad++

I am trying to use jekyll locally to build my website. It is all set up, and I can build and serve and see results at localhost:4000. There are no errors.
The problem is that when I run "Jekyll serve" I can't save files. The save option is greyed out and "ctrl + s" wont work.
I can open and edit the files, can do "Save As" and do other things - basically anything except saving.
I can save files when I am not serving them.
From what I understand, Jekyll is intended to be used to allow saving while serving so we can see our changes as we go. The auto-regenerate function (now a default with serve) supports that use.
I suspect the problem relates to some sort of permissions-type rule stopping me from editing files that are in use.
But because I am self-taught newbie and am not a developer/programmer, I don't know if it is something to do with how I have set up jekyll, notepad++, permissions or something else entirely.
Here is my environment:
Windows 8.1 64-bit
Ruby v2.1.5p
Jekyll v2.5.1
wdm v0.1.0
RubyDevKit
Notepad++ (in admin mode)
Here is what I have tried:
Scaled back the listen gem from v2.10.0 to v2.7.11 (the earlier was listed as safe/tested on a jekyll on windows website)
Scaled back Jekyll from v2.5.3 to v2.5.1 (the earlier was listed as safe/tested on a jekyll on windows website)
Opened Notepad++ in admin mode instead of normal mode.
Tried executing jekyll serve --watch (in case watch enabled saving)
I have not tried re-installing ruby v2.1.3 (listed as safe/tested on a Jekyll on windows website) because Jekyll is otherwise working I don't want to try a re-install except as a last resort - as a newbie I found it a pain to install it on Windows in the first place.
Can anyone help me with this (probably simple) issue?
I thank you for any assistance in advance.
Okay. So I feel really stupid.
But instead of pretending this never happened, I had better post this answer in case anyone else has a blonde 'moment' (read: an entire day) like I did:
Firstly, you can't edit the _config.yml files while serving. You can edit the other files - html, markdown, etc - but not the config file.
Secondly, in Notepad++ you need to make an actual change to a document before the saving option will appear.
I was using the _config file as my 'test' document for regeneration. While I did open up other files to check when I first thought I had an issue, I THINK I may not have made any changes to them - so the option to save them was never activated. After that, I only looked at the config file after making changes.
So, I THINK I may have been able to save while serving all along.
However, if I am wrong and it wasn't my own stupidity (which I strongly doubt), the steps I took which fixed it were:
Those steps outlined in my question; and
A reinstall of Notepad++ (as kindly recommended by 'nerver nerver' who has since removed his/her comment after I said that did not work).
SORRY ... and excuse me while I go and crawl away and hide in shame ...
If the files you were editing at that time was only _config.yml then the expected behavior is that the saved changes are not reflected when the Jekyll server is running/watching.
This is because the server is started after reading the configuration settings in _config.yml, and then changes that happen to that special file after that are not monitored by Jekyll (this is current as of May 2015, in case this gets changed in the future). Currently this is by design. see this SO question as well
What that means is, you have been saving the file when Jekyll is running just fine, the changes just do not get updated. A way to check this is to make some changes, close the file, then open it again (if you want to be extra sure, open in another editor) and see if reflected changes show up.
Changes made to other files in Jekyll when the server is running will be reflected. For example, if I edit a typo in a blog post, edit CSS files or change some formatting, and save in any text editor, Jekyll will regenerate the file from scratch and you should be able to see the changes by refreshing the localhost:4000 page (or whereever your server is running at).
I'm not sure about running Jekyll on Windows, but on a Linux terminal, Jekyll actually notified the number of files that have changed (with a timestamp) and that it regenerated X number of files. Something like
<timestamp> 3 files have changed. Regenerated 3 files in 0.0536 sec..
Lastly, this is probably not your issue, but I thought I might add this here for future reference, do not edit the files inside the _site folder, as they are always deleted and regenerated whenever the server is started again. Editing those files by hand might save and display changes, but the changes will be lost (because they are, statically generated every time by Jekyll)
TL;DR You most probably have been saving your files! The changes in _config.yml are just not reflected once the server is running, and has to be restarted for the new configuration parameters to take effect.

Clearing cache in the server

This is related to my problem here:
Editing velocity template of Liferay changes not showing or takes a while
I've tried to investigate the caching problem and tried different things. Here's what I found out.
I just found out that my css is also delayed in showing the updates. I tweak my css file adding comment and testing it on my browser. Now just requesting it on the URL it will just give me an older version of the file. now if i put a query asking for version, (eg. mystyle.css?v2) it will pull the latest file and it records it. I can even see different version, eg. (mystyle.css?v1) or (mystyle.css?v2. I've cleaned my cache so it's definitely on the server side (i think).
Is there a way I can clear my cache?
Thank You!
you can activate Liferay's developer setting by including the properties that are in ROOT/WEB-INF/classes/portal-developer.properties.
Explanation: Liferay minifies and caches CSS and Javascript - once this is done it will not examine those for changes. The developer settings will disable that.
However, you don't want this setting active in production as this will mean that you'll have to load dozens of files instead of very few combined+minified, well cached, files.
I assume you are using this for development, not in production.
If you're having these problems in production, you should rather work with a proper theme plugin and redeploy that.

Rails 3.1 production assets : big files are cut into pieces

Since I use Rails 3.1 and the assets pipeline I have a big problem when in production mode.
When I did a bundle exec rake assets:precompile, I had errors like
'myjsfile.js' has a invalid UTF-8 byte sequence
in particular with tiny_mce plugin js files.
So I gave up, as everything was working ok in developpment on my mac, and I wrote this line in the production.rb file: config.assets.compile = true
The JS files are therefore generated without errors.
On the other hand, there is a big problem with long files, like jquery.js
Regularly, Rails generates only half of the jQuery file, and the only manner I found to fix temporarily the problem is to go on the js file's URL (http://myapp.com/assets/jquery.js) and refresh the page many times, and after a while the jquery file is entire again.
Then a few days later the problem is back and I've got to do this again.
In fact, it's as if during the compilation of big files, the process stopped in the middle and that the server sent the file half compiled.
Have some of you had this problem? Any idea from where it could come?
I use nginx and passenger on an Ubuntu server for production. I never encounter this problem on my Mac.
In advance, thank's for your help !
The pre-compilation process will fail if you run out of memory on your server. Try doing a rake assets:precompile on your mac and committing the generated assets so that you can get them on your server.
In the longer run, run the precompile on an intermediate CI server, for every successful build.

Sass development workflow issues

I've been trying to adopt Sass into my development workflow. I do primarily front-end development and as such, I am updating stylesheets quite frequently. After endless searching, I have yet to find the answer to what I feel should be a simple question.
I use both Coda and Textmate, so a solution for either would suffice. When developing locally, I open the terminal, get my .scss file watched, then go to town. I save my .scss file, it happily updates my .css file... and then I'm left with the slight annoyance of having to manually select the .css and publish it to the remote server. Its not the end of the world but having to pause my usual dev workflow to manually upload a file I'm not actively in is becoming a nuisance. In Coda, it doesn't detect when a file has been updated outside of Coda, so it isn't marked for publishing. Its driving me crazy. I just need a way to save the .scss file and have the .css file easily/automatically uploaded to the remote server. Any help would be greatly appreciated!
The typical way Sass is used is to design on your local computer while using Sass, and to only upload the CSS (and probably the Sass as well) to the server once you're finished. Another alternative would be to run sass --watch on the server so that it compiles the uploaded Sass files.
I have had a rake task that calls rsync for this kind of cases. That still needs to be run each time but because it uses rsync only the changed files are moved. Now, while reading this I got an idea that shouldn't there be 'rsync watch' somewhere and indeed there seems to be: http://code.google.com/p/lsyncd/
Here's an interesting approach I just read about, installing compass into a small local ruby env, inspired by python virtualenv:
http://rhodesmill.org/brandon/2011/adding-compass/
YMMV (I haven't even tried this myself).
The Sublime SFTP/FTP Plugin can monitor and auto-upload the .css output file whenever it's updated by the SCSS compiler.
Map your project directory to your server
Check it's woking correctly by browsing remote
Right click on your .css output file, and choose 'Monitor File (Upload on External Save)'
Keep the file's tab open in Sublime to ensure it stays monitored/uploaded.
For extra points, have a look at Browsersync or LiveReload.

Resources