All Projects → lifenautjoe → Webpack Starter Basic

lifenautjoe / Webpack Starter Basic

A simple webpack starter project for your basic modern web development needs.

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects
basic
69 projects
ecmascript6
18 projects

Projects that are alternatives of or similar to Webpack Starter Basic

Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+232.07%)
Mutual labels:  webpack, webpack4, starter-kit, sass
Wordpress Starter
📦 A starter template for WordPress websites
Stars: ✭ 26 (-95.29%)
Mutual labels:  webpack, starter-kit, starter, sass
Gulp Pug Starter
Frontend development with pleasure. Pug + SCSS version
Stars: ✭ 228 (-58.7%)
Mutual labels:  webpack, starter-kit, starter, sass
Gulp Scss Starter
Frontend development with pleasure. SCSS version
Stars: ✭ 339 (-38.59%)
Mutual labels:  webpack, starter-kit, starter, sass
Webpack Simple Starter
A simple webpack starter without framework (Like Vue, React, Angular, etc.)
Stars: ✭ 661 (+19.75%)
Mutual labels:  webpack, starter-kit, starter, simple
Tris Webpack Boilerplate
A Webpack boilerplate for static websites that has all the necessary modern tools and optimizations built-in. Score a perfect 10/10 on performance.
Stars: ✭ 1,016 (+84.06%)
Mutual labels:  webpack, webpack4, starter, sass
Webpack Boilerplate
A minimal webpack 5 boilerplate with only Babel, SASS and lodash (optional) on board
Stars: ✭ 404 (-26.81%)
Mutual labels:  webpack, webpack4, sass
Styled React Boilerplate
Minimal & Modern boilerplate for building apps with React & styled-components
Stars: ✭ 198 (-64.13%)
Mutual labels:  webpack, webpack4, simple
Js Library Boilerplate
Javascript Starter Boilerplate - Webpack 4, Babel 7, UMD, Hot Reloading, and more
Stars: ✭ 202 (-63.41%)
Mutual labels:  webpack, webpack4, starter-kit
React Starter Kit
React, Redux, Webpack, Material UI, Boostrap 4, Code Splitting, HMR
Stars: ✭ 229 (-58.51%)
Mutual labels:  webpack, webpack4, starter-kit
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+195.83%)
Mutual labels:  webpack, starter-kit, sass
Frontend Boilerplate
An ES20XX starter with common frontend tasks using Webpack 4 as module bundler and npm scripts as task runner.
Stars: ✭ 224 (-59.42%)
Mutual labels:  webpack, webpack4, starter
example-app
Example app showcasing fulls1z3's Angular libraries
Stars: ✭ 27 (-95.11%)
Mutual labels:  spa, seed, starter
Preact Starter
Webpack3 boilerplate for building SPA / PWA / offline front-end apps with Preact
Stars: ✭ 384 (-30.43%)
Mutual labels:  webpack, starter-kit, spa
Iceberg
Front-End Boilerplate built with React + Babel + Webpack + SASS
Stars: ✭ 144 (-73.91%)
Mutual labels:  webpack, starter-kit, sass
Webpack Starter
✨ A lightweight foundation for your next webpack based frontend project.
Stars: ✭ 1,745 (+216.12%)
Mutual labels:  webpack, starter-kit, sass
Vue Electron Template
An Electron & Vue.js template with Hot-reloading enabled and common Vue plugins, dev, debug and build scripts configured.
Stars: ✭ 260 (-52.9%)
Mutual labels:  webpack, webpack4, starter
node-starter-kit
Node.js / GraphQL project template pre-configured with TypeScript, PostgreSQL, login flow, transactional emails, unit tests, CI/CD workflow.
Stars: ✭ 76 (-86.23%)
Mutual labels:  seed, starter, starter-kit
Vue2 Spa Tutorial
Vue2.x(即将升Vue 3)、 Webpack 4.x、Babel 7.x
Stars: ✭ 267 (-51.63%)
Mutual labels:  webpack, webpack4, spa
Es6 Webpack2 Starter
🚀 A template project for es6/7, webpack2/3, sass and postcss
Stars: ✭ 106 (-80.8%)
Mutual labels:  webpack, starter, sass
Webpack Starter Basic Loo

webpack-starter-basic

forthebadgeforthebadge

dependencies

A simple webpack 4 starter project for your basic web development needs.

Read more on the demo website or continue reading below.

Table of Contents

Motivation

I needed to make a plain ol' "drop your mail to stay updated of ongoing developments" page.

I did not need anything fancy, no frontend framework, no unit testing, simply a starter project that would let me use sass, ES6, load assets, add vendor prefixes, start a dev server, generate sourcemaps and optimize everything for production.

I looked around and all I found were heavily specialized and complicated webpack starter projects (webpack-angular-starter, webpack-react-starter, etc) that are so intertwined with plugins that stripping undesired functionality is almost impossible.

So I did this.

Features

  • Separated development and production webpack settings you can understand
  • Sass
  • ES6
  • Asset loading
  • CSS Vendor prefixing
  • Development server
  • Sourcemaps
  • Favicons generation
  • Production optimizations
  • Mobile browser header color

Requirements

Usage

Substitute PROJECT-NAME for your project name.

Clone the repository

 git clone https://github.com/lifenautjoe/webpack-starter-basic PROJECT-NAME
 cd PROJECT-NAME

Install npm dependencies

 npm install 

Run the kickstart command

npm run kickstart

After the project has been kickstarted

To start the development server

npm start

To build for production

npm run build

To preview the production build

npm run preview

FAQ

When should I use this starter?

You should use this starter if any of the following are true:

  • You want to make a static page. e.g. splash screen, onboarding screen, phaser game, threejs visualization, countdown.
  • You found no good starter kit for whatever you want to do and need a solid place to start from.

Please note: If you are going to use a frontend framework like angular or react, you can of course add the required plugins and configuration but it's normally complicated and quirky enough that it's highly recommended to use one of the existing starter projects such as react-webpack-babel or for angular projects the angular-cli.

Where's the common webpack config?

There is none and that is good thing.

The pattern creates unnecessary confusion over the setup, at the end the config will always be different across environments. People just put booleans everywhere on the common config to switch between these differing configuration options which is just awful to see and confusing for someone who's just starting on webpack.

The only truly shared config between these files are the entry js point and the main html template.

How to load fonts

If you don't support Opera Mini, browsers support the .woff format. Its newer version .woff2, is widely supported by modern browsers and can be a good alternative.

If you decide to use only this format you can load the fonts in a similar manner to images.

In your webpack.dev.js and webpack.prod.js add the following

module.exports = {
    // ..
    module: {
        rules: [
            // ..
            {
                test: /\.woff$/,
                loader: 'url-loader',
                options: {
                    // Limit at 50k. Above that it emits separate files
                    limit: 50000,
                    // url-loader sets mimetype if it's passed.
                    // Without this it derives it from the file extension
                    mimetype: 'application/font-woff',
                    // Output below fonts directory
                    name: './fonts/[name].[ext]',
                },
            }
            // ..
        ]
    }
    // ..
};

And let's say your font is in the folder assets with the name pixel.woff

You can add it and use it in index.scss as

@font-face {
    font-family: "Pixel";
    src: url('./../assets/pixel.woff') format('woff');
}

.body{
    font-family: 'Pixel', sans-serif;
}

If you would like to support all kinds of font types, remove the woff rule we previously added to webpack.dev.js and webpack.prod.js and add the following

module.exports = {
    // ..
    module: {
        rules: [
            // ..
            {
                test: /\.(ttf|eot|woff|woff2)$/,
                loader: 'file-loader',
                options: {
                    name: 'fonts/[name].[ext]',
                },
            }
            // ..
        ]
    }
    // ..
};

And assuming you have your fonts in the directory assets with names pixel.woff, pixel.ttf, pixel.eot , etc.

You can add it and use it in index.scss as

@font-face {
    font-family: 'Pixel';
    src: url('./../assets/pixel.woff2') format('woff2'),
    url('./../assets/pixel.woff') format('woff'),
    url('./../assets/pixel.eot') format('embedded-opentype'),
    url('./../assets/pixel.ttf') format('truetype');
    /* Add other formats as you see fit */
}

How to load images

In JavaScript

You can require an image from JavaScript like

const myImage = require('./assets/icon.png');

If the image size in bytes is smaller than 8192you, myImage will be a string with the encoded image path such as

data:image/svg+xml;base64,bW9kdWxlLmV4cG9ydHMgPSBfX3dlYnBhY2tfcHVibGljX3BhdGhfXyArICJhc3NldHMvaW1hZ2VzL3RpY2stQ3lydkhSdi5zdmciOw==

If the image size is larger than 8192 it will be a string with the url to the image such as

src/assets/icon.png?hash=5b1f36bc41ab31f5b801

This limit is set so images like icons are not loaded through a request but you can force the loader to give you image urls always by doing the following but should not be necessary. The limit works 90% of the time.

const myImage = require('!!url!/assets/icon.png');

In index.html

If you would like to include an image on your index.html file, place the path of the image in a webpack require statement<%= require(imagePath) %>.

  <img class="splash-title__img"
                     src="<%= require('./src/assets/logo-on-dark-bg.png') %>"
                     alt="webpack logo"></a>

How to install Bootstrap 4

After the project has been kickstarted

Install bootstrap

npm install [email protected] --save

Install bootstrap dependencies.

npm install popper.js --save
npm install jquery --save

Replace the project index.scss with

@import "~bootstrap/scss/bootstrap";

And replace the project index.js with

require('./styles/index.scss');

import PopperJs from 'popper.js';
import jquery from 'jquery';


jquery(()=>{
    console.log('Hello jQuery + bootstrap 4!');
});

To see it all come together, replace the index.html body tag with

<body>

<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Link</a>
            </li>
            <li class="nav-item">
                <a class="nav-link disabled" href="#">Disabled</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="https://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
                <div class="dropdown-menu" aria-labelledby="dropdown01">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">Something else here</a>
                </div>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
        </form>
    </div>
</nav>

<main role="main" class="container">

    <div class="starter-template">
        <h1>Bootstrap starter template</h1>
        <p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
    </div>

</main><!-- /.container -->
</body>

Start the development server and voilà.

npm start

To build for production

npm run build

To preview the production build

npm run preview

⚠️ Please remember to remove the Google Analytics tag in the index.html file as soon as you make the template yours.

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-101423651-2"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'UA-101423651-2');
</script>

Websites using this starter kit on the wild

Have a website online built with this starter kit and would like to add it to the list? Open an issue!


Author Joel Hernandez

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].