Skip to content

A fully functional Webpack boilerplate with a lot of features, built to support static HTML pages generation with EJS and some components to start with

License

Notifications You must be signed in to change notification settings

onyxdevs/webpack-boilerplate

Repository files navigation

Weboack Boilerplate 🚀

Todos

  • Remove file-loader and raw-loader in favor of asset modules.
  • JavaScript Form validation.

Features

Pages

New pages are added in "config/templates", then an EJS file should be created accordingly in "src/pages". Now there is only one page as a demo.

Components

  • alert
    • alert--danger
    • alert--success
    • alert--info
    • alert--warning
  • banner
    • banner--none
  • button
    • btn-bordered
    • btn
      • btn--primary
      • btn--none
      • btn--danger
      • btn--success
      • btn--grey
      • btn--fullwidth
      • btn--has-icon
  • footer
  • form
    • form--limited-width
      • Checkbox
      • File
      • Select
      • Switch
      • Text
  • header
    • main-nav
  • langs
  • news
  • pagination
  • socials
  • text-block

Scripts

Utility functions

Located in "src/assets/scripts/utils.js"

  • resetForm();
  • Logger
    • .debug();
    • .silly();
    • .error();
  • preloadImage();
  • waitForTransition();
  • isTouch();
  • debounce();
  • makeRequest(); // Promisified XHR
  • delay(); // Promisified timeout

Main scripts

Located in "src/assets/scripts/main.js"

  • checkJs(); // Checks JS disabling
  • createGlobalWarning(message); // Creates a global warning message in the body element
  • detectBrowser();
  • setActiveNav();
  • setCurrentYear();
  • hasScrollbar(); // Detects horizontal scrollbar
  • setTargetBlank(); // Add target= "_blank" and rel= "noopener noreferrer" for external links

Parallax

Located in "src/assets/scripts/parallax.js"

Define the parallax type as an HTML attribute for the element (data-parallax= "" ), it takes scale and positionY as a value. Set the parallax strength as an HTML attribute for the element (data-parallax-ratio= ".5" ) Parallax ratio can be specified for each breakpoint like the following: data-parallax-ratio-lg data-parallax-ratio-md data-parallax-ratio-sm

Lazyloading

Located in "src/assets/scripts/lazyloading.js" Styles are in "src/assets/styles/lazyloading.scss"

Each lazy-loaded image should have width and height, and on the wrapping "figure" tag we add its aspect ratio as a "padding-bottom" style rule. Bottom padding is calculated this way:

(height / width) * 100

The HTML markup of a lazy-loaded image is:

<figureclass= "lazy-loading"style= "padding-bottom: 75%;">
<img
class= ""
alt= ""
width= "800"
height= "600"
src= "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
data-src= "./link-to-image"
/>
<spanclass= "lazy-loading__loader"></span>
<noscript><imgsrc= "./link-to-image"alt= "" /></noscript>
</figure>

(600 / 800) * 100 = 75

Styles

We're using BEM methodology for naming.

Helper CSS classes

Spaces

  • .mb-xs
  • .mb-sm
  • .mb-md
  • .mb-lg
  • .mb-xl
  • .mb-subsection
  • .mb-section

Hide elements

  • .hide-md
  • .hide-lg

Alignment

  • .text-left
  • .text-center
  • .text-right

SCSS Variables

You can view/edit the available SCSS variables in "src/assets/styles/abstracts/_variables.scss".

// Colors
$primary-accent:#1c6ef7;
$secondary-accent:rgb(119,223,255);
$main-bg-color:#f4f6f8;
$dark-bg-color:#0f1547;
$dark-bg-color-shaded:#171e5a;
$font-dark-color:#00315c;
$font-light-color:rgba($font-dark-color,0.5);
$border-color:rgba($font-dark-color,0.1);

$success-color:#35c636;
$danger-color:#ed2554;
$warning-color:#de9c3e;

// Border radius
$box-corner:1rem;

// Spaces
$container-spacing:4vw;

SCSS Mixins

You can view/edit the available SCSS mixins in "src/assets/styles/abstracts/_mixins.scss".

  • sm
  • md
  • lg
  • xl
  • xxl
  • abs-center
  • absolute
  • fixed
  • relative

Dependencies

Development

webpack

Babel

Loaders

Plugins

Linters

Production

bootstrapBootstrap is a free and open-source CSS framework directed at responsive, mobile-first front-end web development. It contains CSS- and JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components.

Open Graph Protocol

Change Open Graph Protocol data before production to be dynamic for the current page:

Located in the head tag:

<metaproperty= "og:locale"content= "tr-TR"/>
<metaproperty= "og:type"content= "website"/>
<metaproperty= "og:title"content= "Weboack Boilerplate"/>
<metaproperty= "og:description"content= "" />
<metaproperty= "og:url"content= "https://onyxdev.net/"/>
<metaproperty= "og:site_name"content= "Weboack Boilerplate"/>
<metaproperty= "og:image"content= "LINK_TO_IMAGE"/>
<metaproperty= "og:image:type"content= "image/jpeg"/>
<metaproperty= "og:image:width"content= "1200"/>
<metaproperty= "og:image:height"content= "630"/>
<metaname= "twitter:title"content= "Weboack Boilerplate"/>
<metaname= "twitter:description"content= "" />
<metaname= "twitter:image"content= "LINK_TO_IMAGE"/>
<metaname= "twitter:card"content= "summary_large_image"/>
<metaname= "twitter:image:alt"content= "onyxdev.net"/>

General

How to launch the project

InstallNode.jsand then open the Terminal/CMD and navigate to the project's folder. Run the following command:

npm insatll

Development evnironment

npm start

You can view the development server atlocalhost:8080.

Production build

npm run build

Author

Obada Qawwas

Stay safe 😷