Skip to content

A webpack based vanilla project boilerplate with JavaScript and TypeScript support.

License

Notifications You must be signed in to change notification settings

natinium/vanilla-js-ts-webpack-boilerplate

Repository files navigation

πŸš€ Webpack Boilerplate Project

Project Banner

GitHub Stars GitHub Issues License Build Status

Webpack Babel Yarn TypeScript ESLint Prettier Stylelint Commitizen Semantic Release


πŸ“– Project Overview

This boilerplate provides a robust starting point for modern web applications using Webpack. It integrates a suite of tools for managing, building, and deploying both JavaScript and TypeScript-based projects with ease.

Features:

  • Webpack 5: Optimized build and development configuration.
  • Babel: Modern JavaScript compatibility.
  • PostCSS & SASS: Enhanced styling capabilities with autoprefixing.
  • Linting Tools: ESLint, Prettier, and Stylelint for a clean and consistent codebase.
  • Semantic Release: Automate versioning and changelog generation.
  • Commitizen: Standardized commit messages.
  • TypeScript Support: Easily build and maintain type-safe applications.

πŸ› οΈ Tools & Technologies

This project integrates the following tools to ensure scalability and maintainability:

Tool Purpose
Webpack Bundling JavaScript, styles, and assets.
Babel JavaScript transpilation for broad browser support.
PostCSS Processing and optimizing CSS.
Yarn Dependency management.
Commitizen Interactive and structured commit messages.
Commitlint Enforcing commit message conventions.
ESLint JavaScript linting and code quality.
Prettier Automatic code formatting.
Stylelint CSS/SCSS linting.
Husky Managing Git hooks for pre-commit and commit-msg actions.
Lint-staged Running linters on staged files during commits.
Semantic Release Automating releases and changelogs.
TypeScript Adding static typing to JavaScript.

πŸš€ Getting Started

Follow these steps to set up the project:

Prerequisites:

  • Node.js (v16+ recommended)
  • Yarn (v1.22.22)

Steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo.git
    cd your-repo
  2. Install dependencies:

    yarn install
  3. Start the development server:

    yarn serve
  4. Build the project:

    yarn build

πŸ—οΈ Building a Web App Example

Creating the Project Structure:

  1. Add the following folders and files in src:

    src/
    β”œβ”€β”€ index.html
    β”œβ”€β”€ scripts/
    β”‚   └── index.js
    └── styles/
        └── main.scss
    
  2. Populate files:
    index.html:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Webpack Boilerplate</title>
    </head>
    <body>
        <h1>Hello, Webpack!</h1>
        <script src="./main.js"></script>
    </body>
    </html>

    scripts/index.js:

    console.log('Hello, Webpack!');

    styles/main.scss:

    body {
        font-family: Arial, sans-serif;
    }

Building and Running:

  1. Run the development server:

    yarn serve
  2. Build for production:

    yarn build

Adding Commits with Commitizen:

Use cz commit to add standardized commits:

cz commit

Releasing with Semantic Release:

Automate versioning and changelog:

yarn release

Deploying to Hosting Platforms:

  1. Netlify: Drag the dist folder to Netlify's UI or use CLI.
  2. Vercel: Run vercel deploy from the project directory.

🎯 For TypeScript Projects

Steps to Enable TypeScript:

  1. Ensure ts-loader and typescript are installed.
  2. Rename index.js to index.ts.
  3. Update Webpack entry logic to prioritize .ts files.

Run TypeScript compilation checks:

yarn lint-staged

πŸ“œ Available Scripts

Command Description
yarn serve Start the development server.
yarn build Create a production build.
yarn build:dev Create a development build.
yarn watch Watch for file changes and rebuild.
yarn release Automate semantic versioning.

🌟 Contributions

Contributions are welcome! Feel free to submit a pull request or open an issue.


πŸ“„ License

This project is licensed under the ISC License. See the LICENSE file for details.


About

A webpack based vanilla project boilerplate with JavaScript and TypeScript support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published