5/16/2023 0 Comments Guard livereloadThis is an interesting question you've raised so I built a quick and dirty Flask application which utilizes the livereload library. I am to dumb to get it from their documentation :)ĮDIT: for the sake of completenes here is the Flask app I am using. So I guess an alternative title of my question could be:ĭoes somebody have a working example of Flask + python-livereload? I think the answer is somewhere near to python-livereload from the link above. How can I have a smooth developing experience with Flask without having to hit the F times a day in a browser just to see the results of my changes? I googled and tried several things - with no luck: Here on Stackoverflow most similar questions are related to the auto-reload of the Flask server (-> ). Frontend people have several terms for that: auto reload / refresh, hot reload / refresh (hotreload), live reload / refresh (livereload). This seems to be a standard feature in almost any Javascript framework. What I am realy missing is an automatic Browser refresh after any code change (including static files, templates, etc.). # if Find.find(Dir.pwd).I've started learning Flask to develop web applications. # Look for specified files in the current and child directories. # `drush php-eval "system_rebuild_theme_data() "` I have not experienced this with my Homebrew install but for the default Ruby installation, this is a problem. (update: I now wrap the command in bundle exec which I haven't tested here.) To work around this use guard start -i instead (non-interactive mode). The browser extension complains that the server is not running. As of this writing, invoking the guard command directly does not work with guard-livereload.Any modifications will be directed to specific Guard extensions based on watch rules. A huge plus of Guard is that it uses a single observer and the extensions handle specific details like communicating with the browser (LiveReload) or telling Compass to compile. Using compass watch or the equivalent in Sass is not required since it is being handled through Guard::Compass. In your project folder, start the Guard, enable the Browser plug-in and start editing. # $ compass compile -e production -force # css_dir = "css" sass_dir = "css-sass" fonts_dir = "fonts" javascripts_dir = "js" images_dir = "img" relative_assets = true output_style = ( environment = :production ? :compressed : :expanded ) This can be done through the command line # with the following. When compiling for production, this # should be flagged as :production. # sass_options = false # Compass configuration: # Development is the default environment. # Chrome Canary support (Applies to Webkit Nightlies as well.): # Firefox Extension: # Set to true to enable. new # Enable Sass inspection directly from the browser. guardfile attached to this gist into your home folder then type: $ bundleĬd to your project and compass init and configure the generated config.rb file. Open Terminal.app and type (for Command Line Tools only): $ sudo xcode-select -switch / Do not invoke this if you're using the full Developer Tools since it will already be set to /Applications/Xcode.app/Contents/Developer. If you are using the Command Line Tools, a path or development environment must be set manually the first time. You will need a developer account which is free. The other option is to download the Command Line Tools ( Downloads page). It's a heavy download weighing over 1.5GB but it includes an iOS emulator which is great for testing. The easier way is to download the Developer Tools from the Mac App Store which is free. This is needed to compile necessary components for this set-up. You must first get access to the developer tools. This can work for any standalone front-end project. Note that this is not specific to Rails projects. The following instructions is specific to Mac OS X and it works through the command line. If you prefer going through a GUI, that option is available. You will also need a browser component to communicate with LiveReload. This will enable Sass+ Compass with LiveReload through Guard.
0 Comments
Leave a Reply. |