Gulp Compiler is a basic code for automate the tasks of your development environment with the task runner Gulp.
This project has functions for create a server, copy and paste folders/files, compile and compress files and watch his changes.
Is developed with gulp 4.0.0 a task runner and javascript.
Gulp is a toolkit for automating painful or time-consuming tasks in your development workflow, so you can stop messing around and build something.
More information: Introduction to gulp
The SASS and JS compilation tasks pick up the files in the src folder and generate a new dist folder with the results.
-
Input structure folders
src/ sass/ styles.sass js/ scripts.js index.html -
Output structure folders
dist/ css/ styles.min.css js/ scripts.min.js index.html
You can skip this section if you already have NODE, NPM and GULP.
-
-
If you are on MAC you can do it with line of following these steps
- First, install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- Next, install Node (npm will be installed with Node):
brew install node
-
Or install node and npm together with this program: Download
-
-
Install Gulp 4.0.0
-
Install gulp globally
npm install --global gulp-cli
-
Install gulp inside project
npm install gulp
-
-
To test out your
NODE,NPMandGULP, check versions installed-
Check version of node
node --version
-
Check version of npm
npm --version
-
Check version gulp
gulp --version
-
-
Check the globally installed packages
npm list -g --depth=0
-
After installing everything you need, cloning this repository.
git clone https://github.com/beatrizsmerino/gulp-compiler.git
-
For end, you must launch this command, for download the NPM packages and get the dependencies of configuration file package.json.
npm install
-
You can to list available the gulp tasks of this project, using the command
gulp --tasks
After cloning this repository you need to install the required NPM packages.
npm installAfter development you can publish the content of dist folder in Github Pages (gh-pages branch)
npm run deployIn the gulpfile.js of this proyect you can see the gulp tasks developed to compile and compress the SASS and JS, copy and paste the HTML files, create a server and listen to the changes made to reload it (Browsersync + Gulp.js)
This version use gulp.series(), combines task functions and/or composed operations into larger operations that will be executed one after another, in sequential order.
This is the default gulp task
This command is able to:
- Creates the
distfolder if it does not exist. - Generate
html,css,jsondistfolder. - Watch the changes to the files in the
sass, andjsfolders inside thesrcfolder. - Create a server and reloads if there are any changes in those files of
distfolder.
gulpor
gulp htmlCopy
gulp htmlMinify
gulp sassCompile
gulp jsCompile
gulp watchThis create a static server with browserSync package, serves the files from dist folder and opens by default the index.html file in any of these browsers: Chrome & Firefox.
gulp serveor
gulp createServerThis command is able to:
- Creates the
distfolder if it does not exist. - Generate
html,css,jsondistfolder.
gulp buildor
gulp htmlCopy
gulp htmlMinify
gulp sassCompile
gulp jsCompileThis command is able to:
- Creates the
distfolder if it does not exist. - Copies the
htmlfiles from thesrcfolder and pastes thedistfolder. - Minify the
htmlfiles. Collapse white space that contributes to text nodes in a document tree.
gulp htmlor
gulp htmlCopy
gulp htmlMinifyThis command is able to:
- Creates the
distfolder if it does not exist. - Compile the
styles.sassfile (with the import files of partials sass) located atsrc/sass/, add prefixes to properties css, compress the file, create and add a mapping for the debugger styles sass on the browser inspector, apply a Gulp Plugin for Line Ending Corrector (A utility that makes sure your files have consistent line endings)... - Create the
styles.min.cssfile and export todist/css/folder.
gulp cssor
gulp sassCompileThis command is able to:
- Creates the
distfolder if it does not exist. - Get list of files of
pathsFrontobject, compile the files with Babel NPM package, compress it and apply a Gulp Plugin for Line Ending Corrector (A utility that makes sure your files have consistent line endings)... - Export the
scripts.min.jsfile todist/jsfolder.
gulp jsor
gulp jsCompileThis command is able to:
- Create the server.
- Watch the changes to the files in the
html,sassandjsfolders inside thesrcfolder and run the tasks to re-generate the files inside thedistfolder. - Reloads the server if there are any changes to the
html,cssandjsfiles inside thedistfolder.
gulp watchThere is a more complete version in the branch feature/gulpfile-front-back. Go there
- This version separate the frontend and backend.
- It has more tasks as minify images and icons.
