Coder Social home page Coder Social logo

aarnadlr / html-js-webpack4-boiler Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 72 KB

HTML and JS bundling via Webpack 4. HTML and JS live-reloading via webpack-dev-server. It's purpose is to provide a minimal Webpack 4 boilerplate which delivers both HTML and JS live-reloading in development.

HTML 44.44% JavaScript 55.56%
webpack webpack4 webpack-dev-server webpack-boilerplate

html-js-webpack4-boiler's Introduction

SIMPLE WEBPACK 4 BOILERPLATE

HTML and JS bundling via Webpack 4. HTML and JS live-reloading via webpack-dev-server.

This is a simple, functional boilerplate project centered around Webpack 4. It is configured to bundle javascript by webpack's default config (no specials js loaders used), and HTML bundling via html-loader and html-webpack-plugin.

INSTRUCTIONS:

Experience both HTML and JS live-reloading in development by running:

npm run start

Further information

How the project was built:

  1. TERMINAL COMMANDS:
$	mkdir <project> && cd $_

$	npm init -y

$	npm i webpack webpack-cli webpack-dev-server html-loader html-webpack-plugin --save-dev

$	mkdir src

$	touch src/index.js

$	touch src/index.html
  1. Added html5 boilerplate code inside index.html

  2. Added to package.json the new Webpack 4 npm scripts:

"scripts": {
  "start": "webpack-dev-server --mode development --open",
  "build": "webpack --mode production"
}
  1. Added webpack.config.js to the root of the folder.

  2. Added this config code, which gets Webpack to bundle and live-reload the js (by default), and the html (which needs both html-loader and html-wepack-plugin):

const HtmlWebPackPlugin = require("html-webpack-plugin");

module.exports = {
  module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader",
            options: { minimize: true }
          }
        ]
      }
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    })
  ]
};
  1. The boilerplate is complete! To experience both html and js live-reloading in development, run:
npm run start

Thank you and good luck!

a

html-js-webpack4-boiler's People

Contributors

aarnadlr avatar

Stargazers

Park, Soon-Ghil avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.