As I said earlier, when the Css,img,js is removed, watch will listen, but it will not delete the corresponding file.Now implement the clean task and delete the build directory before performing the task.First configure the JS task, set the delete directory.On the basis of the series (d) code, expand it.1. Install Gulp-clean:NPM Install--save-dev
ordinary JSON file;
6.2, it is such a JSON file (Note: The JSON file is not write comments, copy the following to delete the comments):
{
"name": "20180101", "
Version": "1.0.0",
"description": "",
"main": "Gulpfile.js",
"scripts": {
"test": "Echo \" Error:no test specified\ " exit 1"
},
"author": "",
"license": "ISC",
"Devdependencies": {"
Gulp": "^3.9.1",
"gulp-base64": "^0
/fun.js"> script>Post-use HTML:1 href= "css/global.css?v=b40a6f2a9f" rel= "stylesheet" type = "Text/css" /> 2 src= "js/fun.js?v=3a08b5fa87">script> I. Environment configuration (Installation gulp)First install node, NPM (omitted here)Install the Gulp and the plug-ins used, and create the file gulpfile.js under th
Refer to the Packaging tutorial:Http://www.cnblogs.com/tugenhua0707/p/4069769.htmlHttp://www.cnblogs.com/tugenhua0707/p/4982646.htmlHttp://www.tuicool.com/articles/viequayKey points of implementation:1, how to Run Gulp task, join the new good one the following tasks:// Grammar Check function () { gulp.src (' js/**/*.js '). Pipe (Jshint ()) . Pipe (Jshint.reporter (' default ')) ;});Then run on the command line:
Gulp Compression CSSFirst, install the GULP-MINIFY-CSS moduleTip: You need to use the command line CD to switch to the corresponding directory after the installation operation.At the command line, enterNPM Install Gulp-minify-cssAfter successful installation you will see the following information: (Installation time ma
Gulp Troubleshooting Publishing online file (CSS and JS) caching issuesthe reason of this article: the current often online after the release of the document to constantly refresh the page and a long time, the page CSS and JS file to take effect, especially for the current time to do the mall, built-in browser cache is very serious, We used to fix the post-online
Recently need to optimize the project, mainly on the compression of JS and CSS file compression, find relevant information found gulp can achieve the relevant functions, hereby share the use of experience.1. Installing GulpGulp is a front-end build tool based on node. js. So first you need to install Nodejs, install Nodejs.After you complete the NODEJS installation, you need to use NPM to install Gulp.Insta
To prevent the client from caching static resources, we need to rename the static resources by MD5 or timestamps every time we update the CSS or JS. Allows the client to re-request the resource instead of fetching it from the cache. The SRC in the HTML template is then modified accordingly. Of course, there is an additional requirement that static resources need to be optimized for themselves (compression merges).Here is the code for my gulpfile.js:va
Be sure to read this section after you understand the following chapters:
Installing Node and Gulp
Use Gulp to compress JS
Compressing the CSS code can reduce the size of the CSS file and improve the page opening speed.We then convert the rule to Gulp code.
Package.jsonIf you are familiar with NPM, you can use Package.json to save all NPM install--save-dev gulp-xxx module dependencies and module versions.At the command line, enterNPM Initwill be required to complete the project information in turn, not clear can directly enter skipInstallation dependenciesInstall Gulp to project (Prevent Global Gulp upgrade from inc
English Original: spring-cleaning Unused CSS with Grunt, Gulp, broccoli or brunch
Want to improve the speed of the web, generally by reducing response time, standardize the css/js/html and the content of the picture. also through optimized css removing unused css
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.