Here's what the new functionality looks like in action when editing Razor Views/Pages, static CSS and HTML, and server side source code in a controller.įigure 2 - Live Reload in action on static content, Razor pages and server code.Īll that's running here (in my Rider IDE) is dotnet watch run to refresh the server when source code changes are made. You still need to run dotnet watch run for server side code restarts for hard code changes, but for all client side static and Razor file refreshing that is not required. The end result is much quicker and more reliable refreshes of content than with BrowserSync. In this post I'll describe how to build this middleware component that handles the Live Reload functionality natively in ASP.NET Core simply by hooking a couple of middleware directives into your Startup configuration. well, I got that itch to sit down and take a stab at it and the result is this ASP.NET Core Live Reload Middleware Component. While that works just fine, having to run yet another command line utility on top of dotnet watch run just to provide Live Reload functionality is a bit of a pain.Īlso in the last post I mentioned that it would be nice to build some middleware to provide the live client reloading functionality. Gulp.In my last post I discussed how to integrate Live Reload in ASP.NET Core using a third party NodeJs application loaded from NPM called BrowserSync. Gulp.src('./')//server directory (representing the root directory) Zip = require('gulp-zip') //Compression before packaging Webserver = require('gulp-webserver') //local server Uglify = require('gulp-uglify'),//js compression RevCollector = require('gulp-rev-collector'),//file name after replacing md5 Minif圜ss = require('gulp-minify-css'),//minify (minify)CSS Livereload = require('gulp-livereload'),//server file is automatically updated Pngquant = require('imagemin-pngquant'),//png compression Imagemin = require('gulp-imagemin'),//image compression Htmlmin = require('gulp-htmlmin'),//compress html Make sure to install the plugin, part of gulpfile.jsĪutoprefixer = require('gulp-autoprefixer'),//Automatically handle browser prefixĬlean = require('gulp-clean'),//Empty the folderĬoncat = require('gulp-concat'),//Merge files But: it is best not to download the latest version of nodejs, some plug-ins may not support it. Nodejs can be used on the official website or on the official website of the plugin on the Chinese website. Yes (English can be translated online by Baidu and Google). Many of the blog posts described by plugins are from a long time ago, not very suitable for the new version, so, it is best to read the official website plugin documentation, it is the most authoritative and latest, it doesn’t matter if you don’t understand English, just read the code. Using webserver with livereload, you can automatically refresh and preview local (no need for apache server) server-style file preview, what you see is what you get, so cool~! With sublime text3 (a lot of the latest plug-ins have begun to use 3 as the benchmark) is simply an artifact 2. Livereload needs to install a plug-in to realize the automatic refresh of chrome, which is not very convenient to be walled occasionally. Various new plug-ins under nodejs had problems and needed to be reconfigured. After node upgraded from v0.10.26 (in order to match the autoprefixer) to v5.3.0, there was a problem with gulp plug-in compatibility.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |