grrr-gulpfile v4.0.3
Grrr Gulpfile
An opinionated and modular gulpfile. Made with ❤️ by Grrr, a digital creative agency in Amsterdam.
Quick start
Basic installation and configuration is as follows:
Install
Install this package in your project through yarn or npm:
npm install grrr-gulpfile --save-devConfigure
- Create a
gulp.jsonconfig file (see below). - Add the required Babel dependencies for your project. A good starting point is by adding
@babel/preset-env.
npm install --save-dev @babel/preset-envSee the Babel docs for more information. Now specify the Babel config in the gulp.json. See the advanced example for an example, or check the Babel docs for more information.
Run
Run gulp by calling:
gulp --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'Tip: save this as an npm script in your project's package.json, for example:
"scripts": {
"watch": "gulp watch --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'",
"build": "gulp --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'",
"build:staging": "gulp --staging --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'",
"build:production": "BABEL_ENV=production gulp --production --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'"
},- To build, run the build task:
npm run watch - To watch, run the watch task:
npm run watch - To build for a specific environment:
npm run build:production - To run a specific task:
npm run build images
Task configuration
Check the examples for a basic and advanced gulp.json config.
Overriding defaults
The project uses a few sensible defaults for Autoprefixer, sass-lint, eslint (specs and ignores). These defaults can be overwritten:
- The Autoprefixer options used in
sass. These can be specified in thegulp.jsonfile in anautoprefixerobject within thesasstask. - The rules used in
sass:lint. Place a.sass-lint.ymlfile in your project. - The
eslintrules. Place an.eslintrcfile in your project. You can additionally add an.eslintignorefor ignoring (wildcarded) folders or packages specific to your project.
Available tasks
Specify which tasks to run by calling gulp like: gulp [task-name] --cwd . --gulpfile 'node_modules/grrr-gulpfile/gulpfile.js'. Or if speciefied gulp as a script: yarn run gulp <task>.
The individual tasks include:
browsersyncauto refresh and hot reloading in the browsercleanremoves all built assetscopycopies files that don't need processing (like fonts, videos and the favicon)eslintlints js with opinionated rules, which can be overwritten by including your own.eslintrcimagesruns imagemin on all images in theconfig.paths.images.srcand saves the result toconfig.paths.images.distjavascript:buildbundles JavaScript into a single bunle thru Browserify and transpiles it via Babeljavascript:watchwatches for changes and builds the bundle when changes are detectedjavascript:vendorcopies and uglifies vendor files (can also concatenate them)initprints some debug infoiconscreates a svg spritemodernizrchecks js and scss source files for Modernizr tests and creates a custom Modernizr buildrevisioncreates a revisioned filename for each static assetsasscompiles sass with globbingsass:lintlints sass with opinionated rules, which can be overwritten by including your own.sass-lint.yml
The main tasks are:
buildruns all above tasks, exceptbrowsersync(some tasks are dependent on the called environment)watchruns the same tasks asdefaultbut will retrigger when files are changed, and will start browsersync
For more info, jump into the tasks folder.
Contributing
To make changes to this gulpfile, it's best to replace the installed package in a real project with a locally linked development version. This can be done with both yarn or npm. We use yarn in this example; for npm check the npm docs . Inside the root of the grrr-gulpfile repo, run:
yarn linkInside the root of the project you want to test the gulpfile, run:
yarn link grrr-gulpfileWhen you're done, you can publish the changes on npm and unlink the development version by running the following inside the project:
yarn unlink grrr-gulpfile
yarn install7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago