0

I recently started working with Compass and Sass in Netbeans and everything went as expected.

More recently i started working with Sublime Text. The problem is my scss file. As soon as i upload the file, the watch detect a change and attempts to compile, but the upload isn't finished, so it throws an error.

In Netbeans the upload works differently: it creates a new file, and when it's finished the old file is deleted and the new one renamed, so the watch only detects the change when the file is in the server.

During the upload

style.css

style.new.css

After the upload:

style.css

Is there anyway to do the same thing in Sublime Text?

pedroto
  • 643
  • 1
  • 6
  • 9

2 Answers2

0

I'm assuming that you're using the SFTP plugin from here

As far as I can see, there is no configuration option for this in this plugin.

My first suggestion would be to modify your monitoring script to wait a few seconds before compiling, then check the file again to see if it was modified in those few seconds. If it was modified then loop again until it stops being modified.

If you are unable to modify the monitoring system to do that, you're most likely out of luck. I would have to recommend looking for another plugin. I've read through the code of a lot of these different plugins, and a majority use Putty's PFTP and simply uploads the file directly to the server, so it might be difficult for you to find one which works the way you want.

As the SFTP plugin you're using is closed source (notice that you have to pay for it, with nagware just like ST2), you're unable to modify it, or request someone to modify it for you. You'd have to ask the developer to change it. On the other hand if you used a plugin like Mote, the source code is readily available, and you, or someone else can modify it to fit your needs.

Someguy123
  • 1,324
  • 13
  • 27
0

I'm reviewing this issue as I was looking for that precise solution and got it working on Sublime 3 Windows.

Firstly you want to install Ruby Installer (with 'add to path variables' option enabled), and then just open a cmd and type:

gem install compass

Then you'll need to create a Sublime Build System, as originally suggested on a related SASS question. It will run a simple command line. In my case, my config.rb file was located in project/foo/bar/theme and the .scss files in project/foo/bar/theme/scss, to make things scalable and have different possible themes configuration, I left the Build System more relative to the file path. So the build system is as simple as:

{
    "shell_cmd": "compass compile ../",
    "selector": "source.scss",
}

Save this build system, like "Compile SCSS". And, with the .scss file open select it on Tools > Build System > Compile SCSS. Also check Tools > Save All on Build to save on evey build.

Now, if you open your .scss file and hit Ctrl+B, Sublime will run the command, compile the file and save the .scss. So now instead of Ctrl+S to save, just use Ctrl+B. But still SFTP don't automatically uploads the generated .css file.

To do that, you'll need to find the .css file on the left sidebar, right click and go SFTP/FTP > Monitor File (Upload on External Save) and leave the file tab open (thanks to EranSch on this related question).

Now, every time you push Ctrl+B on your .scss file, SFTP will upload it, Sublime will command to compile it, SFTP will upload the .css generated files (given they are open).

teefars
  • 612
  • 4
  • 13