/webpack-boilerplate

A minimal webpack boilerplate to get you started.

Primary LanguageSCSS

πŸ—ƒ webpack Boilerplate

A minimal webpack boilerplate using Babel, PostCSS, Sass and PUG.JS with a small example, grid system and many other Features.

Boiletplate demo

Installation

Clone this repo.

git clone https://github.com/aminejafur/webpack-boilerplate.git

Move to folder.

cd webpack-boilerplate

Run npm or yarn install.

npm i

Usage

Development server

npm run dev

The development server will start at localhost:9000 and a new tab will open in your default browser.

Watching mode

npm run watch

Production build

npm run build

Features

// main.scss
// theme_builder(themeName, themeMap)
  • Auto template files discovery.
// webpack.config.js
/*
 * A function to get all pug or html files with their local path
 * NB : any file with .ignore.{ext} will be ignored
 * dir : The path from where the templates files should be collected
*/
var getTemplates = function (dir) {...
  • Hot reload or HMR exchanges, adds, or removes modules while an application is running, without a full reload. preview

  • Optimize your site or application using Lazy, or "on demand", loading. preview

  • Loading and renaming assets from css, js, pug and html files. preview

  • Sass global import.

  • Work separately and get a fully optimized template.

Before

β”œβ”€β”€β”€css
β”‚   β”‚   main.scss
β”‚   β”‚   style.css
β”‚   └───parts
β”‚       β”‚   custom.scss
β”‚       β”‚   footer.scss
β”‚       β”‚   header.scss
β”‚       └───inc
β”‚               extends.scss
β”‚               functions.scss
β”‚               mixins.scss
β”‚               responsive.scss
β”œβ”€β”€β”€html
β”‚   β”‚   index.pug
β”‚   β”‚   just_html.html
β”‚   β”‚   more.pug
β”‚   β”‚
β”‚   β”œβ”€β”€β”€contact
β”‚   β”‚       index.pug
β”‚   └───includes
β”‚           footer.ignore.pug
β”‚           grid.ignore.pug
β”‚           header.ignore.pug
β”‚           layout.ignore.pug
β”‚           mixins.ignore.pug
β”‚           nav.ignore.pug
β”œβ”€β”€β”€img
β”‚       300.jpg
β”‚       600x200.png
β”‚       background.gif
β”‚       contact.svg
└───js
    β”‚   plugin.js
    └───loads
            noLazyLoad.js
            withLazyLoad.js

After

β”‚   app.js
β”‚   index.html
β”‚   just_html.html
β”‚   lazyloadedalert.app.js
β”‚   more.html
β”‚   style.css
β”œβ”€β”€β”€assets
β”‚   β”œβ”€β”€β”€gif
β”‚   β”‚       4962dd623928824097dba370cc1361a1.gif
β”‚   β”œβ”€β”€β”€images
β”‚   β”‚       e206a6d4a58ed35f9ce520d680d4556e.png
β”‚   └───svg
β”‚           42407f3f7c1291113cb887d93f115840.svg
└───contact
        index.html

Dependencies

Webpack

"webpack": "^4.42.1"
"webpack-cli": "^3.3.11"
"webpack-dev-server": "^3.11.0"

Babel

"@babel/core": "^7.12.3"
"@babel/preset-env": "^7.12.1"

Loaders

"babel-loader": "^8.1.0"
"css-loader": "^5.0.0"
"file-loader": "^6.2.0"
"html-loader": "^1.3.2"
"import-glob-loader": "^1.1.0"
"postcss-loader": "^4.0.4"
"pug-html-loader": "^1.1.5"
"sass-loader": "^10.0.4"

Plugins

"html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.2.1"
"uglifyjs-webpack-plugin": "^2.2.0"
"autoprefixer": "^10.0.1"

TODO

  • Add ESlint.

Resources

Star the repo to support the project ⭐

Feel free to fork, open pull requests and play around. Thanks! ❀️