The hostname on which the webserver can be accessed. You can use the special values 0 or '?' to use a system-assigned port. The task will fail if the specified port is already in use (unless useAvailablePort is set). The port on which the webserver will respond. This task was designed to be used in conjunction with another task that is run immediately afterwards, like the grunt-contrib-qunit plugin qunit task. This behavior can be changed with the keepalive option, and can be enabled ad-hoc by running the task like grunt connect:keepalive. Once grunt's tasks have completed, the web server stops. Note that this server only runs as long as grunt is running. Run this task with the grunt connect command. Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: grunt.loadNpmTasks( 'grunt-contrib-connect') Once you're familiar with that process, you may install this plugin with this command: npm install grunt-contrib-connect -save-dev If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. The main server must include a script tag or a browser extension to the livereload server in order for the browser automatically.> Start a connect web server Getting Started When the 'livereload' option is enabled for 'watch' tasks, it will handle triggering the live reload server for each tasks and when files are modified, which then server back to main server ex: 3000. You'll have the connect web server on separate port ex: port 9000 from your main server. Instead of restarting your server each time a static file is changed, start a static web server using (grunt-contrib-connect). How can I have the browser reload for files listed in a task? Just be aware that with this option enabled, the watch task is more prone to failure. If you would like a faster watch task or need to share the context please set the spawn option to false. It also cripples tasks that rely on the watch task to share the context with each subsequent run (i.e., reload tasks). Spawning does cause a performance hit (usually 500ms for most environments). As well as more efficiently with more complex tasks and file structures. Sandboxing task runs also allows this watch task to run more stable over long periods of time. In an effort to keep the experience consistent and continually produce expected results, this watch task spawns tasks as child processes by default. Each time a user runs grunt a process is spawned and tasks are ran in succession. The goal of this watch task is as files are changed, run tasks as if they were triggered by the user himself or herself. Why spawn as child processes as a default? Please see issues #35 and #145 for more information. If you would like to trigger the live reload server yourself, simply POST files to the URL: Or if you rather roll your own live reload implementation use the following example: It is encouraged to read the documentation for tiny-lr. Live reloading is made easy by the library tiny-lr. Try the connect-livereload middleware for injecting the live reload script into your page. One method is to use Connect middleware to inject the script tag into your page. Since live reloading is used when developing, you may want to disable building for production (and are not using the browser extension). Once installed please use the default live reload port 35729 and the browser extension will automatically reload your page without needing the tag. Please visit how do I install and use the browser extensions for help installing an extension for your browser. Instead of adding a script tag to your page, you can live reload your page by installing a browser extension. Using Live Reload with the Browser Extension Feel free to add this script to your template situation and toggle with some sort of dev flag.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |