How to livereload on a local server?

Asked

Viewed 197 times

0

Recently I saw a lot of information about Gulp.js for front-end development. And I want to use some of its functions like livereload while developing the front end of a java application. But I can’t find information about running Gulp together with another external local server that has database communication.

Someone knows if it is possible, and what is the best way to make Gulp.js work with applications like this?

1 answer

-1

I’m not sure I understand the question but Voce can use the Browser Sync plugin to create the local server that will serve your front-end files with livereload support.

To install:

https://www.browsersync.io/

npm install browser-sync --save

Configuring in the Gulp:

https://www.browsersync.io/docs/gulp/

var gulp        = require('gulp');
var browserSync = require('browser-sync').create();

// Static server
gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "./"
        }
    });
});

To run Gulp together with your application, a path is to configure your IDE, in the project settings I believe it is possible to perform a bash command that will initialize Gulp and its tasks.

  • While this link may answer the question, it is best to include the essential parts of the answer here and provide the link for reference. Replies per link only can be invalidated if the page with the link is changed. - From Review

  • 1

    Thank you! @rubStackOverflow includes the necessary snippets. I’m a beginner here at Stack Overflow but I hope now I can give a good answer.

  • @Danielbeff just a hint, it is at your discretion to follow :) but try to avoid using title formatting for topics. The bold already emphasizes a lot, with the font increased by the whole answer, is a little unpleasant. In this answer here, it was great, but look at these for example: http://answall.com/a/120452/28595 and http://answall.com/a/120447/28595 and also http://en.stackoverflow.com/a/120443/28595. Highlighting in bold or using title formatting in these responses made the response somewhat "allegorical" too.

  • Thanks @Diegof I will improve the formatting !

  • Daniel, but then I need to use the server that runs next to the bank? Thus, I am developing a system, it uses Tomcat as server in eclipse to run the application and make database connections. But I wanted to make livereload work in this development environment. Improved?

  • You need to use Gulp in parallel to the Tomcat server. It runs in a separate process. Monitoring what when changed you want to refresh the page. Based on the example I wrote above it would be something like you run your application on Tomcat and the terminal run the command gulp browser-sync. I don’t know if the explanation is clear, but that’s pretty much it. It is logical that it needs more configurations but ai depends on how this structured the project.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.