Front-end Boilerplate
26 |Using Sass and Gulp
27 | 28 |29 | Here's a quick set-up guide: 30 |
31 | 32 |-
33 |
- Clone Git repo 34 |
- Install by running "npm install" on the commmand line 35 |
- Run "gulp" on the command line. 36 |
├── .gitignore ├── app ├── scss │ ├── _colors.scss │ ├── style.scss │ ├── _typography.scss │ ├── _variables.scss │ └── _global.scss └── js │ ├── script.js │ └── _global.js ├── package.json ├── README.md ├── index.html └── gulpfile.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ -------------------------------------------------------------------------------- /app/scss/_colors.scss: -------------------------------------------------------------------------------- 1 | $white: #ffffff; 2 | $black: #000000; 3 | $dkGray: #303030; 4 | $ltGray: #cecece; -------------------------------------------------------------------------------- /app/js/script.js: -------------------------------------------------------------------------------- 1 | console.log("Load script.js"); 2 | 3 | // Instantiating the global app object 4 | var app = {}; 5 | -------------------------------------------------------------------------------- /app/scss/style.scss: -------------------------------------------------------------------------------- 1 | @import "variables"; 2 | @import "colors"; 3 | @import "global"; 4 | @import "typography"; 5 | -------------------------------------------------------------------------------- /app/js/_global.js: -------------------------------------------------------------------------------- 1 | // Global 2 | app.global = { 3 | init: function(){ // Load all global functions here 4 | console.log("load global functions"); 5 | app.global.loadHeader(); 6 | }, 7 | loadHeader: function(){ // Some specific function 8 | console.log("loadHeader()"); 9 | } 10 | } 11 | 12 | // Run the global stuff 13 | app.global.init(); -------------------------------------------------------------------------------- /app/scss/_typography.scss: -------------------------------------------------------------------------------- 1 | h1, h2, h3 { 2 | font-weight: 700; 3 | margin-top: 0px; 4 | } 5 | 6 | h1 { 7 | font-size: 2rem; 8 | 9 | @media #{$mq-1000-up}{ 10 | font-size: 3rem; 11 | } 12 | } 13 | 14 | h2 { 15 | font-size: 1.5rem; 16 | 17 | @media #{$mq-1000-up}{ 18 | font-size: 2rem; 19 | } 20 | } 21 | 22 | h3 { 23 | font-size: 1.25rem; 24 | 25 | @media #{$mq-1000-up}{ 26 | font-size: 1.5rem; 27 | } 28 | } -------------------------------------------------------------------------------- /app/scss/_variables.scss: -------------------------------------------------------------------------------- 1 | // Media Queries 2 | $mq-620-down: "only screen and (max-width: 620px)"; 3 | $mq-620-up: "only screen and (min-width: 620px)"; 4 | 5 | $mq-760-down: "only screen and (max-width: 759px)"; 6 | $mq-760-up: "only screen and (min-width: 760px)"; 7 | 8 | $mq-900-down: "only screen and (max-width: 899px)"; 9 | $mq-900-up: "only screen and (min-width: 900px)"; 10 | 11 | $mq-1000-down: "only screen and (max-width: 999px)"; 12 | $mq-1000-up: "only screen and (min-width: 1000px)"; 13 | 14 | $mq-1180-up: "only screen and (min-width: 1180px)"; 15 | 16 | $mq-1400-up: "only screen and (min-width: 1400px)"; -------------------------------------------------------------------------------- /app/scss/_global.scss: -------------------------------------------------------------------------------- 1 | html { 2 | box-sizing: border-box; 3 | font-size: 100%; 4 | } 5 | 6 | *, *:before, *:after { 7 | box-sizing: inherit; 8 | } 9 | 10 | body { 11 | padding: 20px; 12 | background-color: $ltGray; 13 | color: $black; 14 | font-family: 'Roboto', sans-serif; 15 | line-height: 1.3; 16 | 17 | @media #{$mq-1000-up}{ 18 | padding: 1.5rem; 19 | } 20 | } 21 | 22 | main { 23 | padding: 20px; 24 | background-color: $white; 25 | border-radius: 15px; 26 | max-width: 1200px; 27 | margin: 0 auto; 28 | 29 | @media #{$mq-1000-up}{ 30 | display: flex; 31 | padding: 1.5rem; 32 | } 33 | } 34 | 35 | .content { 36 | 37 | @media #{$mq-1000-up}{ 38 | flex: 3; 39 | } 40 | } 41 | 42 | aside { 43 | 44 | @media #{$mq-1000-up}{ 45 | flex: 1; 46 | } 47 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend-boilerplate", 3 | "version": "1.0.0", 4 | "description": "Simple front-end boilerplate using Gulp 4", 5 | "main": "gulpfile.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/thecodercoder/frontend-boilerplate.git" 9 | }, 10 | "keywords": [ 11 | "gulp", 12 | "boilerplate", 13 | "html", 14 | "css", 15 | "javascript" 16 | ], 17 | "author": "@thecodercoder", 18 | "license": "ISC", 19 | "bugs": { 20 | "url": "https://github.com/thecodercoder/frontend-boilerplate/issues" 21 | }, 22 | "homepage": "https://github.com/thecodercoder/frontend-boilerplate#readme", 23 | "devDependencies": {}, 24 | "dependencies": { 25 | "autoprefixer": "^10.2.6", 26 | "browser-sync": "^2.27.4", 27 | "cssnano": "^5.0.6", 28 | "gulp": "^4.0.2", 29 | "gulp-concat": "^2.6.1", 30 | "gulp-postcss": "^9.0.0", 31 | "gulp-replace": "^1.1.3", 32 | "gulp-sass": "^5.0.0", 33 | "gulp-terser": "^2.0.1", 34 | "postcss": "^8.3.5", 35 | "sass": "^1.35.2" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Front-end Boilerplate using Sass and Gulp 4 2 | 3 | Using a set of boilerplate files when you're starting a website project can be a huge time-saver. Instead of having to start from scratch or copy and paste from previous projects, you can get up and running in just a minute or two. 4 | 5 | I wanted to share my own boilerplate that I use for simple front-end websites that use HTML, SCSS, and JavaScript. And I'm using Gulp 4 to compile, prefix, and minify my files. 6 | 7 | I also wrote a rather detailed walkthrough on how to get up and running with Gulp 4, as well as migration tips from Gulp 3. 8 | 9 | You can read that on my blog [here](https://coder-coder.com/gulp-4-walk-through). 10 | 11 | ## Quickstart guide 12 | 13 | * Clone or download this Git repo onto your computer. 14 | * Install [Node.js](https://nodejs.org/en/) if you don't have it yet. 15 | * Run `npm install` 16 | * Run `gulp` to run the default Gulp task 17 | 18 | In this proejct, Gulp is configured to run the following functions: 19 | 20 | * Compile the SCSS files to CSS 21 | * Autoprefix and minify the CSS file 22 | * Concatenate the JS files 23 | * Uglify the JS files 24 | * Move final CSS and JS files to the `/dist` folder 25 | 26 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |29 | Here's a quick set-up guide: 30 |
31 | 32 |