PrefaceArticle installed under Windows gulp--Gulp-based front-end integration Solution (a) , the installation of Gulp has been completed, due to the window environment, the article specifically mentions that can be installed Gitbash to replace the window System CMD Command-line tools. This section focuses on the task of using
strategy, gulp let simple tasks simple, complex tasks manageable. 2 build fast: With the power of the Node.js stream, you can quickly build projects and reduce frequent IO operations. 3) Plug-in high quality: Gulp Strict plug-in guide to ensure that plug-ins as you expect the simple high quality work. 4 easy to learn: Through the least API, Master Gulp effortles
Install and use gulp and install and use gulp
Global install gulp (based on node): $ npm install -- global gulp
Enter the project folder, run npm init, fill in relevant parameters, and generate the package. json that records the configuration file information for future project migration.
Go to the project's folder a
Using the Gulp-less plug-in to compile less files into CSS, when there is less file changes to automatically compile less, and to ensure that less syntax error or exception when the normal operation and prompt error message.1, Local installation gulp-lessGithub:https://github.com/plus3network/gulp-lessInstall: Command Prompt executioncnpm install
When gulp-uglify and gulp. watch () are used together, an error is reported (duplicate compression problem), and gulpuglify
Introduction to gulp:
Gulp is a tool for building code during front-end development and a powerful tool for building automated projects. It can not only optimize website resources, in addition, ma
I have the same problem with Webstorm after install a updated version of node. The solution for me is the following:In the block Gulp where webstorm show the list of tasks, Click the cog icon and Select Gulp settingsthe section ' Gulp package ' Add the path to the local Gulppackage (the Gulp inside the Node_modu Les in
Getting Started Guide 1. Global Installation Gulp:NPM Install--global Gulp2. As a project development-dependent (devdependencies) installation:NPM Install--save-dev Gulp3. Under the project root directory, create a name ofgulpfile.jsThe File:var gulp = require (' gulp '); gulp.task (' default ', function () { //put your default task code in this});4. Run Gulp:GulpThe default task, named default, will be ru
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 Gulp-clean2. Locate Gulp
Gulp plug-in (gulp-jmbuild) for front-end WEB build, gulpgulp-jmbuildSource Code address: https://github.com/jiamao/gulp-jmbuild https://github.com/jiamao/gulp-jmbuildgulp-jmbuild
Gulp plug-in for WEB Front-end constructionInstall
Go to the directory you used as the build to
The Gulp command automatically generates the sprite, And the gulp command automatically generatesFile directory description
Gulpfile. js Code
Var gulp = require ('gulp'); var spritesmith = require ('Gulp. spritesmith '); var imagemin = require ('
Speed up, perform our first taskGulp, one of the most popular tools in front-end development.Let's start by creating a Package.jsonwen file in the project directory: running node under the project directoryNPM InitBefore installing gulp, let's take a look at the NPM instal-g command: If you do not add-G, it will be installed in the current project directory. Plus-G will be installed in a global directory.we can see what the global catalog is by using
The common Gulp module methods are:GULP.SRC ()GULP.SRC (' client/one.js '); Specify the explicit file to be processedGULP.SRC (' client/*.js '); Processing all files with the suffix. js in the client directoryGULP.SRC (' client/**/*.js '); Working with the client directory and its subdirectories all files that are. jsGULP.SRC ('!client/main.js ');//handling files other than Client/main.jsThe Gulp.src () method is used to generate the data stream.
Gulp-htmlmin's introduction:Gulp-htmlmin plugin is used to compress the HTML file, can compress the page javascript,css, remove the page space, comment, delete the extra attributes and so on.First, the use of Gulp-htmlmin plug-in1, install "gulp-htmlmin" plug-in command (in the terminal into the project root directory execution)NPM Install--save-dev
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 task in 2.gulp->tasks, such as:3. Add the JS task to the default task sequence:Gul
1. Create a project2. Installing Gulp3. Running GulpCreate a project-Create the project folder named Firstgulp and run NPM init in the Firstgulp directory. NPM Init creates a Packjson file that holds the file information about the project.The green section needs to be entered manually according to the project's own situation, or it can be set to null. The red part is the final generated content.-Of course at the end, you need to confirm the information manually. After confirmation, a Packjson.js
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 caching problem by adding a timestamp to the file, but it doesn't work in the browser, so
Summary: Node Express or node project, to automatically compile sass methods, such as gulp, such as koalas, such as today I want to say this package node-compass.
Method One: Command-line compilation sass:
Method Two: Gulp-sass
Method Three: Node-compass
Method One: Command-line compilation sass:1 Compass CompileEnter confirmation to generate the corresponding CSS codeMethod Two:
Install Gulp-htmlmin with NPM with a single command:NPM Install Gulp-htmlmin--save-devAfter installation, open the Gulpfile.js file, we write a task to specifically compress the HTML, and HTML for a series of processing:var Gulp = require (' gulp '), var htmlmin = require (' gulp
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.