Giter Site home page Giter Site logo

alexnj / sublimeonsavebuild Goto Github PK

View Code? Open in Web Editor NEW
233.0 12.0 31.0 23 KB

Trigger a build the moment you save a file in Sublime Text 2. Works best with web projects that make use of Less, Compass and any other pre-processor or a makefile.

Python 34.23% JavaScript 65.77%

sublimeonsavebuild's Introduction

SublimeOnSaveBuild Sublime Plugin

This is a simple plugin for Sublime Text 2 to trigger a build on each save.

Not all projects might need this plugin, especially if the build operation is lengthy. However, if you have a build that does things like pre-processing CSS via tools like LessCSS and stitching all JS files together, this might be very handy.

Installation

With the Package Control plugin: The easiest way to install SublimeOnSaveBuild is through Package Control, which can be found at this site: http://wbond.net/sublime_packages/package_control

Once you install Package Control, restart ST2 and bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows). Select "Package Control: Install Package", wait while Package Control fetches the latest package list, then select SublimeOnSaveBuild when the list appears. The advantage of using this method is that Package Control will automatically keep SublimeOnSaveBuild up to date with the latest version.

Without Git: Download the latest source from GitHub and copy the SublimeOnSaveBuild folder to your Sublime Text 2 "Packages" directory.

With Git: Clone the repository in your Sublime Text 2 "Packages" directory:

git clone git://github.com/alexnj/SublimeOnSaveBuild.git

The "Packages" directory is located at:

  • OS X:

      ~/Library/Application Support/Sublime Text 2/Packages/
    
  • Linux:

      ~/.config/sublime-text-2/Packages/
    
  • Windows:

      %APPDATA%/Sublime Text 2/Packages/
    

Configuring

There are a number of configuration options available to customize the behavior of SublimeOnSaveBuild. For the latest information on what options are available, select the menu item Preferences->Package Settings->SublimeOnSaveBuild->Settings - Default.

Do NOT edit the default SublimeOnSaveBuild settings. Your changes will be lost when SublimeOnSaveBuild is updated. ALWAYS edit the user SublimeOnSaveBuild settings by selecting Preferences->Package Settings->SublimeOnSaveBuild->Settings - User.

  • build_on_save Set to 1 to trigger a build on save. By default, this is set to 1. I.e., SublimeOnSaveBuild attempts to build all projects. You can change this behavior and build only specific projects by configuring the user specific setting of build_on_save to 0 and project specific setting to 1.

  • filename_filter SublimeOnSaveBuild matches the name of the file being saved against this regular expression to determine if a build should be triggered. By default, the setting has a value of "\\.(css|js|sass|less|scss)$".

Usage

  1. Make sure you have a build operation set up in your Sublime Text 2 project and you are able to build using Control+B (Linux/Windows) or Command+B (OS X).
  2. Hit your favorite shortcut to Saveit should trigger a build.

Good luck!

sublimeonsavebuild's People

Contributors

alexnj avatar jturcotte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimeonsavebuild's Issues

per project settings

I wonder if there's a way to make it possible to switch this off for certain projects... or have I missed something?

File to import not found or unreadable: compass.

I just installed the plugin in ST3 via the package manager but after I save a .scss file I get this error:

Sass::SyntaxError: File to import not found or unreadable: compass. Load path: /Users/george/Downloads/Seamless Use --trace for backtrace. [Finished in 0.3s with exit code 1]

please add execution delay

I have a couple of ST2 plugins which execute on "save action" to do code cleanup and preprocessing. As a result, SublimeOnSaveBuild frequently build the projects before all the code cleanup/preprocessing is done by other plugins and the built files either fail or they are incomplete.

I request officially adding a small delay like 50 ms before executing build. I've adding 50ms execution delay for my local files. If you want, I can provide a patch.

Not listed in Package Control 2

With ST3 and Package Control 2 (Package Control: Install Package) the plugin is not in the list of the packages.

Adding the plugin to Package Control settings (installed_packages):
Package Control: The package "SublimeOnSaveBuild" is not available on this platform.

Build only main scss File

In my Project there are a couple of scss files.
Everytime I change one of those files it get's builded on its own, but those files depend on other files in the hierarchy. So only the main scss file of that Project should get builded at save of any scss file.

Build main SCSS file even if editing only partial file

Hi,

I'm using SublimeOnSaveBuild to build my main styles.scss file, which call several partials files :

  • _mixins.scss
  • _variables.scss
  • etc.

I'm using the tip of noAlvaro to avoid saving on partials (#11)

But I'm lookign for a way to build my my styles.scss file even when I'm editing one of partial file.
For now, I have to save my main styles.scss file after each modification in partial file to build it.

Do you have any idea to do this kind of stuff ?

Broken on Sublime Text 3

Since this morning august 5 2016. Building on save in Sublime Text 3 doesnt seem to be working anymore

Can't exclude partials from being build on save.

I have already tried this setting:

"filename_filter": "(/|\\\\|^)(?!_)(\\w+)\\.(css|js|sass|less|scss)$",

but this makes all files to not build at all. I'm using Sublime Text 4 with newest dart sass and SASS build plugin. Any ideas What I might be doing wrong?

Hide build results on error free build

Is there a way to hide the build view if there are no errors? It's a little distracting to have the build view pop up with

[Finished]

on every save, even for files (such as .js) where this is no compilation.

Thanks for the plugin, a real boon for my Jade compilation.

Not working with jsx

I have a build system set up to compile React jsx files to regular js. The selector is is source.js.jsx. When I've set the "Build System" preference to "Automatic" and I'm on the file and hit command+b, the compiled code builds as expected. However, saving the file does nothing — SublimeOnSaveBuild doesn't appear to work for it, and I can't figure out why.

To reproduce:

  1. Install the JSX syntax
  2. Create a build system in which the selector is source.js.jsx (the command can do anything really, like just echo "test")
  3. Open a file and set its syntax to JSX
  4. Save the file
  5. Try to view build results — you may not be able to, or the results pane will not show any new information because it seems the build never runs
  6. Hit cmd+b, or select Tools > Build. Results will now appear

Windows: CMD windows keep taking focus and stacking up each save

I don't know if this is intended behavior but every save I do I get a new Windows CMD window for this plugin. But ideally:
A.) No window would show up or at least be hidden/minimized
B.) Only one cmd prompt window would be needed but hopefully could close after save?

sasswatch

One press preview in browser

I using Slim language, Live Reload and SublimeOnSaveBuild.

I have to press Ctrl+S 2 times then, to view the result in my browser.

2 time LiveReload

Stack trace, if needs:

    key evt: control+s
    command: save
    {"command": "reload", "apply_images_live": null, "apply_css_live": null, "path": "SashaSlim.slim", "apply_js_live": null}
    INFO:WebSocketClient:Remove from clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x045E5370>
    ERROR:WebSocketClient:WebSocket error
    Traceback (most recent call last):
      File "E:\Sublime Text 3\Data\Packages\LiveReload\server\WebSocketClient.py", line 84, in __init__
        data = self.socket.recv(1024)
    OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом
    INFO:WebSocketClient:Remove from clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x045E5370>
    INFO:WebSocketClient:new client ('127.0.0.1', 54505)
    INFO:WebSocketClient:new client ('127.0.0.1', 54506)
    INFO:WebSocketClient:new client ('127.0.0.1', 54507)
    INFO:WebSocketClient:Add to clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x04BB8D90>
    INFO:WebSocketClient:{'payload': b'{"command":"hello","protocols":["http://livereload.com/protocols/official-6","http://livereload.com/protocols/official-7"],"ver":"2.0.8","ext":"Firefox","extver":"2.1.1"}', 'close_code': None, 'close_reason': None, 'fin': 1, 'hlen': 4, 'mask': b'Ni\xe4X', 'length': 170, 'opcode': 1, 'left': 0}
    INFO:WebSocketClient:Command: hello
    INFO:WebSocketClient:{'payload': b'{"command":"info","plugins":{"less":{"disable":false,"version":"1.0"}},"url":"file:///E:/%D0%9A%D0%B8%D1%80%D0%BE%D0%BB%D0%B0%D0%B9%D0%BD%D0%B0/SashaSlim.html"}', 'close_code': None, 'close_reason': None, 'fin': 1, 'hlen': 4, 'mask': b'\xac\x9d\x06{', 'length': 160, 'opcode': 1, 'left': 0}
    INFO:WebSocketClient:Command: info
    b'{"command":"info","plugins":{"less":{"disable":false,"version":"1.0"}},"url":"file:///E:/%D0%9A%D0%B8%D1%80%D0%BE%D0%BB%D0%B0%D0%B9%D0%BD%D0%B0/SashaSlim.html"}'
    key evt: control+s
    command: save
    {"command": "reload", "apply_images_live": null, "apply_css_live": null, "path": "SashaSlim.slim", "apply_js_live": null}
    INFO:WebSocketClient:Remove from clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x04BB8D90>
    ERROR:WebSocketClient:WebSocket error
    Traceback (most recent call last):
      File "E:\Sublime Text 3\Data\Packages\LiveReload\server\WebSocketClient.py", line 84, in __init__
        data = self.socket.recv(1024)
    OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом
    INFO:WebSocketClient:Remove from clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x04BB8D90>
    INFO:WebSocketClient:new client ('127.0.0.1', 54508)
    INFO:WebSocketClient:new client ('127.0.0.1', 54509)
    INFO:WebSocketClient:new client ('127.0.0.1', 54510)
    INFO:WebSocketClient:Add to clients table <LiveReload.server.WebSocketClient.WebSocketClient object at 0x04B60E30>
    INFO:WebSocketClient:{'payload': b'{"command":"hello","protocols":["http://livereload.com/protocols/official-6","http://livereload.com/protocols/official-7"],"ver":"2.0.8","ext":"Firefox","extver":"2.1.1"}', 'close_code': None, 'close_reason': None, 'fin': 1, 'hlen': 4, 'mask': b'4\x86\x94\x0c', 'length': 170, 'opcode': 1, 'left': 0}
    INFO:WebSocketClient:Command: hello
    INFO:WebSocketClient:{'payload': b'{"command":"info","plugins":{"less":{"disable":false,"version":"1.0"}},"url":"file:///E:/%D0%9A%D0%B8%D1%80%D0%BE%D0%BB%D0%B0%D0%B9%D0%BD%D0%B0/SashaSlim.html"}', 'close_code': None, 'close_reason': None, 'fin': 1, 'hlen': 4, 'mask': b'E\xc5N\x87', 'length': 160, 'opcode': 1, 'left': 0}
    INFO:WebSocketClient:Command: info
    b'{"command":"info","plugins":{"less":{"disable":false,"version":"1.0"}},"url":"file:///E:/%D0%9A%D0%B8%D1%80%D0%BE%D0%BB%D0%B0%D0%B9%D0%BD%D0%B0/SashaSlim.html"}'

If needs the necessary information, as I have set LiveReload, I give it.

Question: Can I do so that I can see a preview in the browser after one press Ctrl+S, not two? Maybe other instruments, not necessarily LiveReload.

Thanks for great plugin.

avoid the param windows on typescript compile

I'm using this package with sublime text 3, hoping to make it compile Typescript files into javascript.
the best i was able to achieve is that on save it opens the build params line, then i hit enter and it does the work. but it's annoying. i want just to save and have the js file ready, like in vs or other tools.
is there a way to avoid this parameters window? there are no params anyways.

Add SASS build options

Hi,

Nice package, I use it a lot with ST3.

Could you add options so it will compile SASS as minified?

Excude partials?

Hi,

Isn't this supposed to work in order to excluse partials (filename's starting with a _ )?
"filename_filter": "^[^_]+\\.(sass|less|scss)$"

Respect the "working_dir" setting

A project that uses the working_dir setting will not work as expected with OnSaveBuild.

Example project configuration snippet:

"build_systems":
[
    {
        "name": "CouchApp Push",
        "working_dir": "../myFolder",
        "cmd": ["couchapp", "push", "local"]

        "windows": {
            "cmd": ["couchapp.bat", "push", "local"]
        }
    }
]

Here I have several sublime-project files stored in a single directory for convenience, and this relative folder reference will run fine without the plugin installed, and will fail when the plugin is installed. Moving the sublime-project file to the same difrectory and removing the working-dir setting fixes the issue.

Can't find node command (ST3)

I want to use SublimeOnSaveBuild to automatically use ng-annotate for a angular project.
I have this error when I save a .js file :

No matching processes belonging to you were found
/bin/sh: node: command not found
[Finished in 0.2s with exit code 127]

Can you help me with this ?

Allow ASCII Characters

Using any ascii characters in the .scss file breaks the build.

Example:
.anchor:after{ content:'⚓'; }

Will yield this error:
Error: Invalid US-ASCII character "\xE2"

"save_on_focus_lost"

Sublime Text has a nice option called "save_on_focus_lost". It automatically saves files when switching to a different file or application.

Build doesn't work when you switch to a different tab.

Tested on Windows 7 64-bit.
Sublime Text version 2.0.1, build 2217.

Change "Usage" terminology

The first point under "Usage" in the readme could more intuitively explain how to use the plugin.

I incorrectly interpreted

  1. Make sure you have a build operation set up in your Sublime Text 2 project...

as "add a build system to your sublime project file" instead of "select a build system other than Automatic".
i.e. I expected Automatic to run the build I added to my project file on save.

The following may be more intuitive:

  1. Make sure you have selected a build system from "Tools -> Build System" and that you are able to build using Ctrl+B (Linux/Windows) or Cmd+B (OS X).

Build on save got broken after installing less2css

Hi, onsavebuild worked fine in sublimetext 3 so far. I tryed to install less2css today
and suddenly my .scss files are not compiled to .css an save anymore. I can
compile them by cmd + B but of course it should work by ust saving the file.

I know this is no direct OnSaveBuild issue but maybe you can give me a hint how I can
restore the trigger of cmd + B on save. I allready removed and reinstalled OnSaveBuild
via package manager - that didn't work.

Best regards,
Karsten

Avoid saving on partials

Hi,

Just tried to manage a way around SASS partials (the files starting with "_"), so as to avoid building the project unnecessarily. So I've adjusted the filename_filter setting, leaving it as the following:

{
    "filename_filter": "\\.(css|js|sass|less)|^[^_].+\\.(scss)",
    "build_on_save": 1
}

I've tested the new regex in some editors and it is working fine. But SublimeOnSaveBuild still compiling archives with the initial "_" character.

Am I missing something?

Thank you.

Watcher for build on partial save

I'm trying to configure this plugin so that it builds my main stylesheet when I save a partial so that I don't have to save the main scss everytime

Right now I just have my custom build

{ "cmd": ["sass", "--update", "$file:${file_path}/../${file_base_name}.css", "--stop-on-error", "--no-cache"] }

And then my SublimeSaveOnBuild settings

{ "filename_filter": "(/|\\\\|^)(?!_)(\\w+)\\.(css|js|sass|less|scss)$", "build_on_save": 1 }

So how I can I make this trigger when I save partials in my structure?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.