This is a sample of Gulpfile to be used with config instead of "re-developing" manually each gulpfile.
- NodeJS 4+
- NPM if you don't have choice, Yarn instead (recommended).
- Gulp 4
- Options:
--prod
If specified, will run clean-css and uglyfyjs when dumping the assets.
- Gulp commands:
images
Dumps the sources in theconfig.images
parameter from image files.less
Dumps the sources in theconfig.less
parameter from LESS files.sass
Dumps the sources in theconfig.sass
parameter from SCSS files.css
Dumps the sources in theconfig.css
parameter from plain CSS files.js
Dumps the sources in theconfig.js
parameter from plain JS files.dump
Executes all the above commands.watch
Executesdump
, then watches all sources, and dump all assets once any file is updated.
- Logs: when you run a command, there are plenty of
console
calls that log things that happen, which allow you to know what is happening, what files are managed, updated. All with time info.
- Copy/paste the
gulpfile.js
and thepackage.json
files in the root directory of your project (or execute the command below). - Install dependencies:
- Choice 1: Run
npm install && npm shrinkwrap
command- What is
shrinkwrap
? It's something you should use more often if you usenpm
.
- What is
- Choice 2: Run
yarn install
command, and ayarn.lock
will magically appear
- Choice 1: Run
- Update the
config
variable in thegulpfile.js
file so it fits to your needs. - To view how this gulpfile works, simply run
gulp default
orgulp
without any argument. - Enjoy!
Or execute these commands in your project's root:
curl -LOk https://raw.githubusercontent.com/Orbitale/Gulpfile/gulp4/gulpfile.js -o gulpfile.js
curl -LOk https://raw.githubusercontent.com/Orbitale/Gulpfile/gulp4/package.json -o package.json
yarn install
gulpfile.js
or package.json
files.
If you are using gulpfiles in many projects (this one or any gulpfile), you can use this script to install gulp globally:
npm install -g "gulp4"
Remember that you still have to run npm install
to have all gulp plugins, else nothing will work.
If you are already using this file and want to "update" to the new versions (there are some new versions sometimes), just take everything from our gulpfile starting from the line containing this:
/*************** End config ***************/
Starting from this line, you can copy/paste everything, unless you have your own logic inside the gulpfile, then you'll have to keep your code, just be careful not to lose your own code 😉