Front-end Gulp DevStack
Gulp stack for building optimized static pages and exports for collaboration between coders and programmers.
Table of contents (click to expand)
Typical use cases
- Developing landing pages or prototypes (
npm run dev). - Building carefully compiled and formated files for collaboration (
npm run export). - Building the final (production) bundle, ready for deployment (
npm run deploy).
When you want to build whole web sites from the data sources as API or many markdown files, go with Static Page Generators (SGC). For example Gridsome (VueJS), Gatsby (React) or Hugo (Go) will work for you much better.
Features
- SEO-friendly β Open Graph and Twiter Cards markup, self/canonical.
- User-friendly β image optimizations, favicons, webmanifest and all sources minification to smallest bundle.
- Developer-friendly β ESLint, Prettier, Remark, Stylelint via tasks or with Husky and Lint staged.
- Separate tasks for Development, Export and Build with automatic renaming and hashing all critical assets.
- Ready for implementation Git based CMS as Tina CMS or Netlify CMS etc. β Front Matter (Markdown files metadata and content).
- HTML temlates uses Nunjucks. Fully customisable Bootstrap 5.3.x extended with BEM. JavaScript processed with Babel or injected from CDN or as static files.
| Preprocessing / Linting | π οΈ Development Postprocessing |
ποΈ Export Postprocessing |
π― Build Postprocessing |
|
|---|---|---|---|---|
| CSS | SASS / Stylelint | PostCSS (Autoprefixer, prettify) | PostCSS (Autoprefixer, prettify) | PostCSS (Autoprefixer, cssnano, PurgeCSS) |
| JavaScript | Babel / ESLint | only concatenate | concatenate & uglify | concatenate & uglify |
| HTML | Nunjucks | prettify | prettify | minify |
| Content & Metadata | Markdown / Remark | |||
| JPG, SVG | imagemin | imagemin | imagemin | |
| PNG | UPNG.js | UPNG.js | UPNG.js | |
| Fonts | gulp-google-webfonts | gulp-google-webfonts | gulp-google-webfonts | |
| Favicons | Favicons | Favicons | ||
| Workflow hints | Browsersync |
Something more under the hood
- Linting all commit messages by CommitLint, see more about Semantic Commit Messages and Conventional Commits
- Commit guide on the CLI by git-cz
- Automatic releases with Release It!, see more about Semantic Versioning
- Changelog with Conventional Changelog
- Gitflow
- Build and deployment to FTP.
Getting Started
Installation
-
Node.js and npm are required.
-
Clone the repository into the new project directory
PROJECT_NAMEgit clone https://github.com/cebreus/gulp-devstack/ ./PROJECT_NAME
-
Go to project directory
PROJECT_NAMEand install npm dependenciescd PROJECT_NAME && npm i
-
Optional clenup (click to expand)
-
Clean
CHANGELOG.md> CHANGELOG.md -
Change or remove
LICENSE.txtbyrm LICENSErm LICENSE
-
Change this
README.mdaccording to your new project or replace it from the templatecurl https://gist.githubusercontent.com/cebreus/a6010a2a95a4f2375830b0af3193f2f9/raw/cde6d9c68f2605b34eb5b8710bd553e7ad28a678/minimalistic-readme > README.md -
Change these data in the
package.jsonaccordng to your new projectnamedescriptionkeywordsauthorlicenseprivaterepositoryhomepagebugs
-
Project structure
-
Specialties designed for GitHub./.github -
/content/pagesβ each*.mdis data source for templates; each file corresponds to the template./src/pages/*.htmlsite.mdβ contains default data for all pages
-
Common Gulp tasks for Development workflow. Do not edit unless you know what you are doing./gulp-tasks -
Common Gulp tasks for Build workflow. Do not edit unless you know what you are doing./gulp-tasks-build -
Common Gulp tasks for Export workflow (compiled and formated bundles). Do not edit unless you know what you are doing./gulp-tasks-export -
Development directory. This is place of developers creativity. Change anything as you wish./src/gfxβ graphic assets/jsβ JavaScripts, all files in this directory will be concatenated into one file; files are sorted by name/scss_variables.scssβ copy from the Bootstrap core for your customization.bootstrap.scssβ copy from the Bootstrap core for your customization.c-article.scssβ example of the BEM component Article.custom.scssβ main stlesheet for customization of the project. Contains additions and overriding of the Bootstrap.u-debugger.scssβ only in Developmnet workflow adds outline and info around HTML element with [BEM namespaces](BEM component. Outlines objectso-, componentc-and utilitiesu-. To enable functionality set$show-debuggertotruein the file_variables.scss.u-show-grid.scssβ only in Developmnet workflow adds small box into bottom right corner with information about current viewport size accoding to Bootstrap. In the file_variables.scssset$show-gridtotrueand see bars as Bootstrap grid columns.
/templates/pagesβ every*.htmlfile will be rendered as standalone HTML page on own URL (directory name). Meta attributes passes from according Markdown file in./contentdirectory./partialsβlayout-default.htmlβ main layout which extends files in./templates/pages
font.listβ tab-delimeted format for gulp-google-webfonts which download font files and CSS to the project.
-
Content of this directory will be coppied into target (temp, export or build directory)./static/.well-known/security.txtβ definition of the security policies. Further infohumans.txtβ detailed public information about project e.g. team members, technologies etc. Further info
-
/(root).browserslistrcβ Browserslist configuration to share target browsers versions between different front-end tools as Autoprefixer, Babel etc. The configuration is a copy of the Bootstrap configuration in this repo..editorconfigβ basic definition of code formatting for different code editors and IDEs. These settings are used as a baseline for language specialised linters in this repo. Further info.env.exampleβ template of the.envfile, where stored fragments of the code shouldnβt be part of repoβs codebase, e.g. login to FTP..eslintignoreβ list of the files and directories to be ignore by Eslint..eslintrc.ymlβ Eslint configuration to specify and configure rules of JavaScript linting. Further info.gitattributesβ path-specific settings used by Git. Settings that Git applies to certain subdirectories or subsets of files - for example EOL (End Of Line) setting. Further info.gitignoreβ list of path-specific pattern to be ignored (not commited) by Git. Further info.prettierignoreβ list of the files and directories to be ignore by Prettier..prettierrc.ymlβ Prettier configuration to specify and configure rules of language specific code formatting..release-it.ymlβ Release It! configuration to specify behaviour of the versioning and package publishing related tasks..remarkignoreβ list of the files and directories to be ignore by Remark..remarkrc.ymlβ Remark configuration to specify and configure rules of Markdown lintng..stylelintignoreβ list of the files and directories to be ignore by Stylelint..stylelintrc.ymlβ Stylelint configuration to specify and configure rules of CSS (SCSS) linting. See used plugins! Further infocommitlint.config.jsβ commitlint configuration to help adhering to a commit convention.gulpconfig.jsβ configuration for π οΈ development Gulp filegulpfile.js. Contains variables and setting which are specific for Development workflow purposes.gulpconfig-build.jsβ configuration for π― build Gulp filegulpfile.build.js. Contains variables and setting which are specific for Build workflow purposes.gulpconfig-export.jsβ configuration for ποΈ export Gulp filegulpfile.export.js. Contains variables and setting which are specific for Export workflow purposes.gulpfile.jsβ Gulp π οΈ development configuration and definition of automation tasks. Further infogulpfile.build.jsβ Gulp π― build configuration and definition of automation tasks. Further infogulpfile.export.jsβ Gulp ποΈ export configuration and definition of automation tasks. Further infoCHANGELOG.mdβ list of the notable changes in this project.LICENSEβ Open source license of Git repository. It enables others to freely use, change and distribute the project in the repository. Further infopackage.jsonβ NPM packages specifics. It lists the packages (with their versions) your project depends on. Further infopackage-lock.jsonβ NPM manifest. Automatically generated with change ofnode_modulesorpackage.jsonif working with NPM. Holds information about which versions of each dependency were installed in order to get consistent installs across machines. Further infoREADME.mdβ Itβs me!
Workflow
Development
Starts watchers, compilers etc., for development with hot-reload in the browser.
-
Run development task
npm run dev
-
Open Browser on URL
http://localhost:4000or what you see in command-line. -
Modify files in
srcdirectory a sub-directories. -
Changes in the configuration files requires a restart. Stop dev task and run
npm run devagain.
Production Build
Produces optimized files in production quality.
-
Run build task
npm run build
-
See files in
builddirectory.
Export Build
Produces optimized and formated files with good readability of the code.
-
Run build task
npm run export -
See files in
exportdirectory.
Updates from devstack to your existing project
-
create a branch in your projectβs repo (e.g.
devstack-update)git checkout -b devstack-update
-
Add this Gulp DevStack as a remote to your project
devstackgit remote add devstack git@github.com:cebreus/gulp-devstack.git
-
Fetch remote
git fetch devstack
-
Merge
devstack-updateto your branch (e.g.master) (use--allow-unrelated-historiesif necessary)git merge master
-
solve eventual conflicts
-
push the devstack-update branch
git push -u devstack-update
-
create PR from
devstack-updateto your master
Inject devstack to your new project
git remote add devstack git@github.com:cebreus/gulp-devstack.git
git fetch devstack
git merge devstack/master --squash --allow-unrelated-histories
git commit -m "feat: Gulp DevStack init"
git merge devstack/blankenize --squash --allow-unrelated-histories -X theirs
git commit -m "refactor: Gulp DevStack clean-up"Don't forget to customize for your project by replacing some strings or deleting files like in section "Optional clenup".
Roadmap and Known issues
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what makes the open-source community such a fantastic place to learn, inspire, and create. Any contributions you make are much appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your changes (`git commit -m "feat: Add some AmazingFeature")
- Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
It is distributed under the MIT License. See LICENSE for more information.
Contact
Jaroslav VrΓ‘na β cebreus@live.com, web site
Project Link: github.com/cebreus/gulp-devstack