Sublime SFTP - Upload compiled css when sass file saved - css

I'm developing html/css in Sublime. I'm writing my css with sass and using Sublime's build system to generate the css file on file save. It's also configured to upload on save using the SFTP plugin.
My problem is that the generated css file doesn't get uploaded as that isn't the file I've directly saved. I've tried to see if there is a way for the SFTP plugin to upload all files that have been modified locally, but it doesn't seem to support that.
Is there anything I can do to achieve this?

I'll throw my solution into the mix, just in case anyone stumbles on this as I did and wants to stick as close to a solely ST-based workflow as possible. If you're using the SFTP package for ST, there is an option to monitor files for external saves.
Unfortunately, using the ST build system to compile my SASS somehow slipped by SFTP. SASS CLI's watch utility, however, triggers the upload just fine. Once set, presuming the target file remains open, SFTP will upload it after each build.
To recap,
Open target file, followed by the command palette. Enter SFTP: Monitor File (Upload on External Save)
Start whatever CLI watch/build utility you prefer, for me, Sass: sass --watch app.scss:app.css
Leave target file open, otherwise the SFTP monitor seems to cease.
Enjoy!
NOTE: You can also enable file monitoring from the sidebar by right clicking on the file you wish to monitor and selecting...

SFTP has an option for that. Search on Package control for SFTP > Monitor file. Once selected, "SFTP monitoring" will appear on bottom command info. Now on every save, both sass and complied css will be uploaded to their respetive folders.

Because Sublime SFTP doesn't seem to support this, you'll probably have to go a different route.
I would recommend using something that monitors your css folder, and automatically uploads any changes to your server. Using good ol' fashion WinSCP (if you're on Windows) would work, but any way to sync folders works.
http://winscp.net/eng/docs/task_keep_up_to_date

I ended up scrapping SFTP and using ExpanDrive. Fits my workflow perfectly.

I'm still using Sublime SFTP to upload script files (js/css/php etc). Usually I press shortcuts to upload opened files (Ctrl Alt U + N). But it was annoying especially with frequent trial disclaimer window.
I wrote a simple tool on nodejs which monitors project folder and uploads any file on its change. It's not perfect but made my workflow much comfortable: https://github.com/liberborn/live-uploader.

Also note that you can map a local copy of your files to the remote copy, by opening the local folder in Sublime, then right-click on it in the sidebar, and select SFTP/FTP -> Map to Remote... to set up the connection, making sure to enter the appropriate remote_path to map the folder to.
Then you can do your build/compile, open the local compiled file(s), right-click on the code, and in the SFTP/FTP menu, select the Monitor File option.
Now when you build again in future, with the compiled file(s) still open, they will get uploaded to the server shortly afterwards (as well as being refreshed in Sublime when you switch tab to view them).

There's a way to force Sublime SFTP plugin to upload compiled files, if your CoffeeScript/Sass/Less files are compiled when you save a file.
Go to Sublime Menu → Tools → Developer → New Plugin..., and copy-paste the code below:
import sublime, sublime_plugin, re, os
class SftpAutoUpload(sublime_plugin.EventListener):
def is_remote_file(self, file_name):
while file_name != os.path.abspath(os.sep):
file_name = os.path.dirname(file_name)
sftp_config = file_name + '/sftp-config.json'
if os.path.exists(sftp_config):
return True
return False
def on_post_save_async(self, view):
window = view.window()
file_name = view.file_name()
# Upload compiled files to SFTP when saving a file (Coffee, Sass, Less)
if self.is_remote_file(file_name):
extensions = { 'coffee': 'js', 'less': 'css', 'sass': 'css' }
for extension, compiled in extensions.items():
matches = re.match('^(.*)\.'+extension+'$', file_name)
if matches is not None:
compiled_file = matches.group(1) + '.' + compiled
if os.path.exists(compiled_file):
new_view = window.open_file(compiled_file)
window.run_command("sftp_upload_file")
new_view.close()
Save the file as sftp-auto-upload.py. Restart Sublime.
What the plugin does is the following:
it checks if you're editing a CoffeeScript, Sass or Less file;
if a compiled file exists, then the compiled file is opened in Sublime
SFTP: Upload File command is executed, and the compiled file is closed.
All this happens almost instantly, so you don't even notice that a new tab was opened.
The code can be improved, but it does the trick.

Related

Open txt file through notepad using Qt

I'm trying to open a text file in notepad using Qt but it keeps giving me this message:
What I'm using is the following:
QProcess::startDetached("C:\\Windows\\system32\\notepad.exe", { ":/notes.txt" });
Qt compiles resources added to a resource file into a binary format. Notepad (or any external tool) does not have access to the individual files that are part of it. If you want to provide access to the file to an external program, you'll have to either distribute your txt file alongside your application or write it to a temporary file on the fly before trying to open it.
After doing either of the two, you can then open your file with an external tool by passing the full path to QProcess::startDetached like it has been mentioned in David Cornejo's answer.
You need to pass the full path to the file as an argument to the QProcess::startDetached() function.
For example:
QProcess::startDetached("C:\\Windows\\system32\\notepad.exe", { "C:\\path\\to\\notes.txt" });

How to add .conf files to Pycharm

I am running a Django Project in PyCharm and deploying it to EC2 in AWS. The guide tells me to use nginx I have to create a file called nginx_someName.conf however no matter how much I try I can't get create a .conf file and write in it. I tried to download Scala to Pycharm using the question below IntelliJ IDEA plugin to fold .conf files? but somehow the Scala plugin is no longer available on Pycharm. (Scala was supposed to be a plugin that allows .conf files)
However I am able to create .config files So I named my file nginx_someName.config Is it the same thing
Image below in relation to #yole's solution
Following #yole's advise related image Reached here now..
Click this button as shown on the screenshot:
use .ini instead .conf in pycharm for configuration best answer I can come up with for now
create a new file with .ini

PhpStorm LESS Watcher configuration

I am using PhpStorm 8 to work on some LESS files.
variables.less gets imported from styles.less.
When I save variables.less only a variables.css is being made.
How do I configure the watcher to transpile only styles.less > styles.css and automatically upload styles.css?
Here's my current config: Current watcher config http://www.bilder-upload.eu/upload/e60eb3-1432718715.jpg
You need to enable Track only root files option so that only main file will be compiled.
If it does not work -- delete your existing watcher and create new one from scratch. Here is mine (as an example -- works fine for me).
For automatic upload (deployment) -- have a look at the official manual: https://confluence.jetbrains.com/display/PhpStorm/Deployments+in+PhpStorm
If configured correctly but it still does not work -- it's possible (quite likely) that your Output paths to refresh is not pointing to a correct file (after File Watcher execution IDE does not re-read whole project looking for changes -- only files pointed here).

automatically compile less file on save of a imported less file

I have split my less/css into several files grouped by certain categories, so the single files stay easy to maintain. Though I only want to have one css file which gets imported into the layout.
For this I have - how I call it - a master less file which imports all the others like config, forms, layout and so on.
Now the problem is, that for example WinLess or all the other copilers i tried, only monitor the save of my master file, and only then compiles it. However this is stupid, because this file nearly never gets any changes. So what I would like to have is something, that detects changes on the imported less files and then only compiles the master file.
Does anyone know any tools, which are capable of that?
Or how do you manage your less files to bypass this problem?
Further Info: I have mapped the server directory locally via SSH and edit the files in there, i.e. the files are only pseudo local. They are on the server but accessible with a local path over a drive letter. The compiler should be able to work with that setup.
Thanks for the answers!
In all honesty, your best bet is to actually use Less's own compiler which will of course be the most up to date option. It will be done through command line but it's the best way to know that everything is correct, working and up-to-date.
All the information can be found in the Less Documentation Here
More information about compiling with imports can be found HERE
The latest version of WinLESS does report that it has automatic re-compiling when an #import file is changed so it could be that your version of WinLESS is out of date. (See HERE - 3rd bullet point under Features)
Alternatively, see if you can get it to work on purely local files. If this works, it may be an issue with the compiler not being able to do asynchronous checks over SSH.
I use Notepad++ with the NppExec-plugin on-save script. If you make a convention decision to always name your primary file "master.less" you can use this script:
NPP_CONSOLE 0
NPP_SAVE
if $(EXT_PART) != .less goto end
"C:\Node.JS\node_modules\.bin\lessc.cmd" -x "$(CURRENT_DIRECTORY)\master.less" > "$(CURRENT_DIRECTORY)\master.min.css"
:end
You can do something similar with any editor that supports batch scripting (like Stewartside suggests)

How do I make LessCSS output css which is then uploaded to webserver

I want to use LessCSS for some of its benefits, but I don't want the user to have to download the less.js file or have it do any processing client side - I don't even want to have LessCSS working on my webserver. I'd like to write some Less, push it through LessCSS and then upload the resulting CSS file to the webserver.
Ideally I'd like LessCSS to process the Less file as when I save it in NetBeans and automagically pop out a css file.
Any ideas where to start?
Have a look at my blog entry (http://blog.nickdamoulakis.com/2012/04/php-less-css-and-cssjs-minify.html) where I list and describe a method I use.
Basically, I have a tab open in my browser that points to my compile.php.
Whenever I want to 'compile' files, I just press F5 and it compiles JS-->MIN.JS, LESS-->CSS and CSS-->MIN.CSS.
An INI file specifies which directories to process.
It is not a fully automated process but it works for what I need it to do.
I hope it is of use to you.
Check out SimpLESS. It's a standalone application, but it will monitor a folder for changes in .LESS files and auto compile them into CSS.

Resources