Git Product home page Git Product logo

webpack_boilerplate's Introduction

Webpack boilerplate for static website

Webpack is a module bundler but we often want to split modules into single files such as .html, .css, .js to make it work in your deployment environment or you want to pass normal HTML/CSS code to your client. This boilerplate creates traditional static website file structure. Nothing will be bundled except for .js file.

Demo

https://webpackboilerplate.netlify.com/

Tools

  • Pug
  • Sass
  • ES6 Transpile

File Structure

.
+-- public/ (Deploy this directory)
    +-- .keep
    +-- index.html
        +-- assets/
            +-- images/
            +-- javascripts/
            +-- stylesheets/
        +-- posts/
            1.html
+-- src/
    +-- main.js (Import js and css you want to pick up)
    +-- assets/
        +-- images
        +-- javascripts
        +-- stylesheets
    +-- pages/ (Picked up by HtmlWebpackPlugin)
        +-- index.pug
        +-- posts/
            +-- 1.html
+-- webpack.config.js

Let's Get Started

# Start development
$ npm start

# To Emit files into /public
# Use this as a build command (e.g. Netlify) 
$ npm run build

Add New HTML Page

  • Add a .pug file in pages/.
  • Add 'your/path/to/page.html' as htmlPlugin's argument.
  • Restart webpack (npm start).

Add New CSS / JS

  • Add a .js or .scss/.sass file in /src/assets.
  • Import them in /src/main.js file.
  • Restart webpack (npm start).

/src/main.js is an entry point to pick everything up in this project. You can see the setting in webpack.config.js.

Update Packages

https://github.com/tjunnone/npm-check-updates

$ npm install -g npm-check-updates

# To check latest versions
$ ncu

# To Upgrade everything to the latest version
$ ncu -u

webpack_boilerplate's People

Contributors

shunwitter 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.