Code Monkey home page Code Monkey logo

webpack-single-page-boilerplate's Introduction

Webpack Single Page Boilerplate

A boilerplate for a single page app using webpack

Build Status Dependency Status

Why should I use it

So far, this is the best way I found to build files like index.html into webpack. This boilerplate handles Javascript, CSS and HTML bundling using only webpack.

Usage

The general directory structure is:

.
├── assets
│   └── images
│       └── favicon.png
├── babel.config.js
├── config
│   ├── default.json
│   └── production.json
├── index.html
├── package.json
├── README.md
├── src
│   ├── index.js
│   └── styles
│       └── index.scss
└── webpack.config.js
  • Your javascript entry point is src/index.js
  • Your style entry point is src/styles/index.scss

config node module is being used, this way you can define your settings under config/{NODE_ENV}.json and build your project with different settings for different environments. Just change your NODE_ENV environment variable to build your project:

Example

# Uses 'config/default.json'
$ npm run build
# Uses 'config/default.json' overwritten by 'config/production.json'
$ NODE_ENV=production npm run build
# Uses 'config/default.json' overwritten by 'config/staging.json'
$ NODE_ENV=staging npm run build
# Uses 'config/default.json' overwritten by 'config/anything.json'
$ NODE_ENV=anything npm run build

All config variables are available under the CONFIG global:

# config/default.json
{
  "MY_API_URL": "https://nihey.org"
}
// => "https://nihey.org"
console.log(CONFIG.MY_API_URL)

About

This boilerplate includes the following loaders:

  • babel-loader: Enable ES6 features.
  • file-loader: Call require for binary files.
  • img-loader: Optimize image compression.
  • json-loader: Call require for json files.
  • scss-loader: Style your pages with scss.
  • style-loader: Add exports of a module as style to DOM.

It also includes the following plugins:

  • extract-text-webpack-plugin: Extract css text from bundled styles.

License

This code is released under CC0 (Public Domain)

webpack-single-page-boilerplate's People

Contributors

nihey avatar nkronlage avatar

Watchers

 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.