devDependencies value to indicate that the project needs to rely on gulp.DependenciesYou can indicate to other participants in the project that the node module in the development environment and production environment is lazy and want to know more about it to see the Package.json documentation.Fifth step: Create a new Gulpfile file and run the GulpAfter installing gulp we need to tell it what to do for us, first of all we need to figure out what task
This section implements JS compression, before the implementation of compression, the first configuration JS task, set the source directory and output directory.On the basis of the series (c) code, expand it.1. Locate Gulp->config.js and configure the source directory (SRC->IMG) and output directory (BUILD->IMG) for JS:New JS
12345678910111213
! DOCTYPE HTML> html> head> link rel="stylesheet" href="Css/[email protected] @hash"> /head> body> div>Hello, world ! /div> img src="Img/test.jpg?r[email protected] @hash" alt="" c24>/> /body> /HTML>
4, Configuration Gulpfile.js4.1. Basic use (Add a version number to the page reference URL to clear the page cache)JavaScript
12345678
var
our unit tests automatically before committing.Code AnalysisWe write JavaScript often have some potential bugs, such as forget to add a semicolon, a variable does not wait, use some JavaScript code analysis tool, can help us to check some common problems. HTML reference JavaScript or CSS files such as we need to use Bower to refer to the front-end JavaScript and CSS third-party libraries, if the version upgrade, add Remove and so on by hand to modify the HTML, first more time-consuming, the sec
tool to run our unit tests automatically before committing.Code AnalysisWe write JavaScript often have some potential bugs, such as forget to add a semicolon, a variable does not wait, use some JavaScript code analysis tool, can help us to check some common problems.HTML referencing JavaScript or CSS filesFor example, we need to use bower and the like to reference the front-end JavaScript and CSS third-party library, then if the version upgrade, add Remove and so on by hand to modify the HTML,
after the prompt execution cnpm Gulp install--save-dev;
7.2. This example takes gulp-less as an example (compiling the less file), and the command prompt executes the cnpm install gulp-less--save-dev;
7.3, will be installed in the Node_modules gulp-less directory, the directory has a
them to the dist/ directory.Default taskgulp.task(‘default‘, function(){ gulp.run(‘lint‘, ‘sass‘, ‘scripts‘); gulp.watch(‘./js/*.js‘, function(){ gulp.run(‘lint‘, ‘sass‘, ‘scripts‘); });});At this point, we create a default task that is based on other tasks. Use .run() methods to correlate and run the tasks defined above, use the .watch() method to listen for file changes in the specified directory, and
NPM Install Gulp--save-dev
What is Gulp?Gulp is a new generation of front-end project building tools, you can use Gulp and its plug-ins to your project code (LESS,SASS) to compile, you can compress your JS and CSS code, or even compress your pictures,
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
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
node. JS-based automation Tool GulpWhat is Gulp?Gulp is a stream-based code-building tool in the front-end development process, and it is the building block of the automation project; she can not only optimize the site resources, but also in the development process a lot of repetitive tasks can be automated using the correct tools, she can not only very happy to
Before, I introduced to learn to install and configure the front-end Automation Tool gulp, feel gulp indeed than grunt configuration is much simpler, so I decided to further study gulp, went to the Internet to check the data, found that gulp can also automatically add version number, This function is usually when I upd
Use gulp to compress html, js, css, and images of the project,1, download and install node access http://nodejs.org, and then click the big greeninstallClick to directly run the program after the download is complete, and everything is ready. Npm will be installed along with the installation package. 2. Open the code line.Node-v // view the node version. if the version is displayed, the installation is succ
The project update iterations that are being done are more frequent, the front-end code is often packaged for deployment, and manual integration of code files is cumbersome and time-consuming, so it is decided to use Gulp instead of manually doing this work.Front-end static resources in the release of the update will face the problem of client browser cache (refer to this article), to solve this problem can be used in two ways: The overriding method (
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.