A Webpack starter kit for frontend development

View in another language:
A Webpack starter kit for frontend development
Categories
Resources
Technologies
Author

Benoit Schneider

Managing Technical Director
Date

We will go through in the most simple way possible in this article how to use Webpack in HTML/CSS code development, with the example of the starter kit we use at Outsourcify that contains a Webpack 4 configuration.

Why should we use a task runner?

It’s been a while now that front-end web development – coding that usually involves only HTML, CSS and Javascript – implies using task runners based on the command line tools, usually with the help of NPM the NodeJS package manager. It doesn’t mean that NodeJS is involved at all in the project but it needs to be installed in order to run locally some Javascript development tools.

These tools are needed for a few essential front-end tasks :

  • pre-proccessing SCSS into CSS
  • bundling into a single file all the Jaavscript
  • minifying both CSS and JS
  • image optimization
  • in our case our build also generates some HTML pages with the use of templating, a Webpack plugin will assembele together templates, usually header and footer templates can then be reused on all page.

The goal is globally from various SCSS, JS and HTML files to generate an optimized static website that’s ready to publish online. Of course all of this can still be done differently, some tasks can be handled with specific softwares (like Koala) or IDE (Visual Studio can handle it), but you’ll never get the flexibility of a command line tool.

Why does Webpack does it better?

Nowadays when developing front-end it’s mostly Webpack that is used, but other alternatives are always possible, Grunt and Gulp for example. We used Gulp for a while, along with Bower which was commonly used to bundle jQuery libraries a few years ago until the Bower team stopped maintaining it and recommended to switch to Webpack (which we did around that time as it seemed obvious if even the Bower guys were telling you to do so). We also used Browserify which would allow us to get the result in real time in a browser when coding, saving a file would reload the browser immediately. All of this is handled by Webpack plugins now.

Webpack handles natively a lot of the tasks, it also has a whole ecosystem of open source plugins that can do pretty much anything you want, examples of what it allows are:

  • different configs for development/production, minification is not need in dev mode for example
  • hot module replacement : no more reloading, saving a file automatically renders the compilation and reload the browser
  • modern JS : transpile ES2015+ Javascript so it can still run on older browsers

The original purpose of Webpack is to bundle Javascript, which means uniting all the javascript code of a project and its dependencies into a single Javascript file that can be referenced from the HTML. It’s nearly mandatory when developing with React.JS or Vue.JS for example. This article deals with the use of Webpack not only to group your front-end Javascript, but also the CSS and HTML.

A strater kit to bootstrap HTML projects

Our objective here would be to create HTML pages for a website, let’s say we received a Adobe XD file which holds the design for several web pages, they all share the same header and footer.

Creating the Webpack configuration can be a bit tedious, especially for smaller projects where you dont have time to start from scratch, that’s why we have this starter kit to kickstart quickly a very simple design to HTML project. You can find the starter kit on our Github account:

https://github.com/outsourcify/HTMLWebpackStarterKit

It holds these files :

├── src
│   │   contact.html
│   │   index.html
│   ├───fonts
│   │       font
│   ├───images
│   │   │   logo.png
│   │   ├───general
│   │   │       vertical-horizontal.png
│   │   └───icons
│   │           star.png
│   ├───js
│   │       index.js
│   ├───scss
│   │   │   main.scss
│   │   │   postcss.config.js
│   │   ├───components
│   │   │       _button.scss
│   │   │       _form.scss
│   │   │       _icon.scss
│   │   │       _normalize.scss
│   │   │       _typography.scss
│   │   │       _variables.scss
│   │   └───pages
│   │           base.scss
│   ├───blocks
│   │        footer.html
│   │        header.html
│   └───pages
│            index.html
│            about.html
│            contact.html
├── .gitignore
├── package-lock.json
├── package.json
├── README.md
└── webpack.config.js

It’s just something to start from and can be adapted easily. Here we have 2 HTML files (index.html and contact.html), which should use the same footer.html and header.html. The SCSS here is purely custom but it could be based on a framework like Bootstrap, the Javascript is in the index.js. We’ll get to those later.

First you will need to have Git and NPM installed on your computer. NPM is installed with with Node.js, it is the Node Package Manager which allows you to download Javascript libraries needed in the project (Webpack is a Javascript library as well as all its plugins). Everything in NPM is open source of course.

  • Cloning the repository

With Git installed, you can usually with a right click open the “Git Bash” command line software in an folder, then you just need to launch this command to download the repository :

git clone https://github.com/outsourcify/HTMLWebpackStarterKit.git .

The url is found by clicking on Github’s “Clone or download” green button. You can either leave the dot in the command line, or git will create a folder named “HTMLWebpackStarterKit”.

  • Installing the packages

The first thing to do is to install all dependencies. This is done with a simple command line.

npm install

What it does it checking the packages.json file for dependencies and devDependencies and install it in a “node_nodules” folder. The “devDependencies” are libraries that are not used in your project but libraries that are used to generate the project’s code during development : webpack but also babel, a Javascript compiler, Terser which minifies Javascript (it replaced UglifyJS), different CSS tools (SASS, autoprefixer), there is also webpack-dev-server, a development server that provides live reloading of the browser.

The “package-lock.json” file tells NPM which exact versions of each library we want to install as the “package.json” file itself just gives the minimum required version. This starter kit was just updated with the latest versions of Webpack and its plugins, it works well as it is now, the “package-lock.json” makes sure you get versions that work well together. All the 20 different libraries used are managed by different teams that constantly improve them but they might bring incompatibilities so they should be upgraded with care.

Run your first tasks

You’re now ready to run a few tasks included in the package.json file :

"start": "webpack-dev-server --mode development --open",        
"build": "webpack --mode development",        
"dist": "webpack --mode production",        
"watch": "webpack --watch --mode development"

To run the development build task, just launch :

npm run build

This will create a “build” folder with your generate HTML, CSS and JS as well as images. The dist task will do the same but will create production ready files that are minified.

npm run start

This command will open a browser with the index.html page and everytime you save a SCSS or JS file it will reload the browser automatically.

Understand the Webpack config

Logically, the “webpack.config.js” holds the instructions to tell Webpack which tasks we want it to execute.

Basically it tells which libraries to use, and what to do with them, where are the source files (here the “entry” files are all in the “src/” folder) and where to output the generated files (here in “build/”). It also tells for each file type which “loader” should be used, JS is transpiled and compiled, SCSS is prec-processed, images are compressed etc, each by the appropriate plugin.

Check the code in this file, its pretty much self explanatory, the purpose of this article is not to explain how to configure Webpack but how to start quickly with our starter kit.

Add some Javascript libraries

Now it’s time to code your HTML, add sections to your pages. The important part is here to follow the folder structure in the “src/” folder, the different HTML files you wish to generate should be in the “src/pages” folder, any new HTML page created will have to be added here.

Then in order to add a block into your page, use this syntax:

<%= require('html-loader!../blocks/header.html') %>

This build includes the HTML beautify plugin to make your code look pretty.

Instead we could also use a Javascript templating engine such as Pug, but this simple syntax works fine if you prefer to write HTML directly.

A starter kit to generate multiple HTML pages

You now have a starter kit which creates SEO friendly HTML pages, with a single minified CSS and JS file added to each. Of course we’re far from addressing the whole scope of what NPM and Webpack provides in this article. We will describe in the next articles how to import a CSS framework like Bootstrap and a Javascript libray, for example a slider plugin easily.

Benoit Schneider · Managing Technical Director

After studying to become a Web Engineer at the UTBM in France, Benoit experienced working in various IT departments of large companies in Paris as a web developer then as a project manager before becoming a freelance web consultant in 2010, and finally co-founded Outsourcify in Thailand.

Have a project in mind?
Let's start your project today

Contact Us
Have a project in mind?
Let's start your project today

Related blog articles

Technologies

Agility Isn’t Dead. It’s Finally Becoming Real

April 29, 2026

Agility Isn’t Dead. It’s Finally Becoming Real
Agility Isn’t Dead. It’s Finally Becoming Real
Technologies

AI Is Reshaping Web Development — But Not in the Way People Think

March 18, 2026

AI Is Reshaping Web Development — But Not in the Way People Think
AI Is Reshaping Web Development — But Not in the Way People Think
Technologies

Will AI Replace Developers? A Reality Check From the Field

March 11, 2026

Will AI Replace Developers? A Reality Check From the Field
Will AI Replace Developers? A Reality Check From the Field
Technologies

Teaching AI and Software Development at Chulalongkorn University: A Two-Hour Conversation That Went Well Beyond the Slides

February 23, 2026

Teaching AI and Software Development at Chulalongkorn University: A Two-Hour Conversation That Went Well Beyond the Slides
Teaching AI and Software Development at Chulalongkorn University: A Two-Hour Conversation That Went Well Beyond the Slides
Technologies

Skipping Figma Doesn’t Mean Skipping Design

February 18, 2026

Skipping Figma Doesn’t Mean Skipping Design
Skipping Figma Doesn’t Mean Skipping Design
Technologies

Vibe Coding Rescue: From MVP to Scalable Platform

February 15, 2026

Vibe Coding Rescue: From MVP to Scalable Platform
Vibe Coding Rescue: From MVP to Scalable Platform
Technologies

Building AcadAsia: A Technical Deep Dive into Thailand’s International School Advisory Platform

February 11, 2026

Building AcadAsia: A Technical Deep Dive into Thailand’s International School Advisory Platform
Building AcadAsia: A Technical Deep Dive into Thailand’s International School Advisory Platform
Technologies

How to Choose the Right WordPress Agency: Beyond the Sales Pitch

January 20, 2026

How to Choose the Right WordPress Agency: Beyond the Sales Pitch
How to Choose the Right WordPress Agency: Beyond the Sales Pitch
Technologies

Astro Joins Cloudflare: The New Standard for High-Performance Web Architecture

December 14, 2025

Astro Joins Cloudflare: The New Standard for High-Performance Web Architecture
Astro Joins Cloudflare: The New Standard for High-Performance Web Architecture
Technologies

WooCommerce vs Shopify: Which Platform Fits Your Project?

November 21, 2025

WooCommerce vs Shopify: Which Platform Fits Your Project?
WooCommerce vs Shopify: Which Platform Fits Your Project?
Resources

Building a B2B Product: Laying the Right Foundations from Day One

September 29, 2025

Building a B2B Product: Laying the Right Foundations from Day One
Building a B2B Product: Laying the Right Foundations from Day One
Technologies

A ResTech MVP in 1 Month

September 19, 2025

A ResTech MVP in 1 Month
A ResTech MVP in 1 Month
Technologies

Our Headless WordPress Journey with Astro.js and Vue.js

September 2, 2025

Our Headless WordPress Journey with Astro.js and Vue.js
Our Headless WordPress Journey with Astro.js and Vue.js
Resources

Why Taking Over a Development Project Is Always a Challenge

August 11, 2025

Why Taking Over a Development Project Is Always a Challenge
Why Taking Over a Development Project Is Always a Challenge
Technologies

From Vibe-Coded Prototype to Production-Ready: How Client Mockups Accelerate Our Work

August 5, 2025

From Vibe-Coded Prototype to Production-Ready: How Client Mockups Accelerate Our Work
From Vibe-Coded Prototype to Production-Ready: How Client Mockups Accelerate Our Work
Technologies

Outsourcify’s 2025 Tech Stack Driving Digital Excellence

August 4, 2025

Outsourcify’s 2025 Tech Stack Driving Digital Excellence
Outsourcify’s 2025 Tech Stack Driving Digital Excellence
Outsourcify Story

What Our Clients Say About Us: A Look at Outsourcify’s Google Reviews

July 30, 2025

What Our Clients Say About Us: A Look at Outsourcify’s Google Reviews
What Our Clients Say About Us: A Look at Outsourcify’s Google Reviews
Outsourcify Story

The Agency Developer: Beyond the Code

July 14, 2025

The Agency Developer: Beyond the Code
The Agency Developer: Beyond the Code
Resources

A Website Is Non-Negotiable in 2025 — But Its Content May Be Training AI

July 9, 2025

A Website Is Non-Negotiable in 2025 — But Its Content May Be Training AI
A Website Is Non-Negotiable in 2025 — But Its Content May Be Training AI
Resources

SaaS Tools Annual Cost Comparison for a 35-User Team – and What You Can Learn from Our Journey

June 11, 2025

SaaS Tools Annual Cost Comparison for a 35-User Team – and What You Can Learn from Our Journey
SaaS Tools Annual Cost Comparison for a 35-User Team – and What You Can Learn from Our Journey
Technologies

Recent Projects at Outsourcify: A Behind-the-Scenes Series

June 2, 2025

Recent Projects at Outsourcify: A Behind-the-Scenes Series
Recent Projects at Outsourcify: A Behind-the-Scenes Series
Resources

A Guide to Thailand’s Online Payment Gateways

May 4, 2025

A Guide to Thailand’s Online Payment Gateways
A Guide to Thailand’s Online Payment Gateways
Technologies

10 Programming Practices Worth Rethinking

April 29, 2025

10 Programming Practices Worth Rethinking
10 Programming Practices Worth Rethinking
Outsourcify Story

The Outsourcify Story #1: Lessons from a decade in Web Development

March 23, 2025

The Outsourcify Story #1: Lessons from a decade in Web Development
The Outsourcify Story #1: Lessons from a decade in Web Development
Technologies

Outsourcify partners with Sisense: the Power of Business Intelligence

February 16, 2025

Outsourcify partners with Sisense: the Power of Business Intelligence
Outsourcify partners with Sisense: the Power of Business Intelligence
Technologies

The 8 Archetypes of Software Engineers Every Team Needs (And How to Harness Their Superpowers)

February 6, 2025

The 8 Archetypes of Software Engineers Every Team Needs (And How to Harness Their Superpowers)
The 8 Archetypes of Software Engineers Every Team Needs (And How to Harness Their Superpowers)
Outsourcify Website

Eco-friendly and Accessible Websites: Building a Sustainable Digital Future

December 10, 2024

Eco-friendly and Accessible Websites: Building a Sustainable Digital Future
Eco-friendly and Accessible Websites: Building a Sustainable Digital Future
Technologies

The impact of API-centric approaches on software development

November 27, 2024

The impact of API-centric approaches on software development
The impact of API-centric approaches on software development
Technologies

How to know you can trust a web agency: A practical guide

November 15, 2024

How to know you can trust a web agency: A practical guide
How to know you can trust a web agency: A practical guide
Technologies

Who’s watching? A guide to privacy on websites and protecting your data

November 14, 2024

Who’s watching? A guide to privacy on websites and protecting your data
Who’s watching? A guide to privacy on websites and protecting your data
Technologies

Understanding the differences between MVP and MMP for smarter product development

November 13, 2024

Understanding the differences between MVP and MMP for smarter product development
Understanding the differences between MVP and MMP for smarter product development
Technologies

The top 3 strategic pitfalls that can derail a tech startup

November 8, 2024

The top 3 strategic pitfalls that can derail a tech startup
The top 3 strategic pitfalls that can derail a tech startup
Technologies

How to avoid AI project failures: lessons from automation

November 7, 2024

How to avoid AI project failures: lessons from automation
How to avoid AI project failures: lessons from automation
Technologies

The top 3 pitfalls facing CTOs and how to overcome them

October 31, 2024

The top 3 pitfalls facing CTOs and how to overcome them
The top 3 pitfalls facing CTOs and how to overcome them
Technologies

How do we extract the needs of a startup in the context of a Define Scope – Requirements Workshop?

October 29, 2024

How do we extract the needs of a startup in the context of a Define Scope – Requirements Workshop?
How do we extract the needs of a startup in the context of a Define Scope – Requirements Workshop?
Technologies

The vital role of a product owner in your web project

October 25, 2024

The vital role of a product owner in your web project
The vital role of a product owner in your web project
Technologies

How to choose a web agency: Top platforms to help you find a reliable partner

October 15, 2024

How to choose a web agency: Top platforms to help you find a reliable partner
How to choose a web agency: Top platforms to help you find a reliable partner
Technologies

The breadth of expertise required for Web Development

October 9, 2024

The breadth of expertise required for Web Development
The breadth of expertise required for Web Development
Technologies

Running daily, a day early: cron jobs for everyone

October 7, 2024

Running daily, a day early: cron jobs for everyone
Running daily, a day early: cron jobs for everyone
Company Activities

Behind the scenes: Triple baby party & reflecting on our company’s sociology

October 4, 2024

Behind the scenes: Triple baby party & reflecting on our company’s sociology
Behind the scenes: Triple baby party & reflecting on our company’s sociology
Technologies

Caching: Our number one suspect

August 9, 2024

Caching: Our number one suspect
Caching: Our number one suspect
Technologies

What is a database and how do you choose one for your web application project?

June 18, 2024

What is a database and how do you choose one for your web application project?
What is a database and how do you choose one for your web application project?
Technologies

Outsourcify’s expertise with the Astro framework

June 11, 2024

Outsourcify’s expertise with the Astro framework
Outsourcify’s expertise with the Astro framework
Technologies

What is an API and how does Outsourcify use them?

May 22, 2024

What is an API and how does Outsourcify use them?
What is an API and how does Outsourcify use them?
Technologies

Which LLMs are we using to facilitate the development at Outsourcify?

May 10, 2024

Which LLMs are we using to facilitate the development at Outsourcify?
Which LLMs are we using to facilitate the development at Outsourcify?
Technologies

Integrating an AI service for Real Estate

January 19, 2024

Integrating an AI service for Real Estate
Integrating an AI service for Real Estate