Giter VIP home page Giter VIP logo

webpack-application-template's Introduction

Framework neutral template for building apps with Webpack and Babel

Features

  • Builds clientside web applications with webpack and babel.
  • A webserver with hot reload when developing your app.
  • Also builds seperate css, fonts and other files. (Either from seperate entry points for css, or from require statements in JavaScript code.)

Goals

  • This template will act as a starting point for creating web apps.
  • The project template should include a development web server.
  • The template should contain as few devDependencies as possible, so that it will be easy to evolve the build configuration as different packages are updated or made obsolete.

How to use this template project

  1. Copy the files and structure of this project. (If you use git clone you would probably want to remove the .git directory before initializing your new repo.)
  2. Create your app in the source folder.
  3. Modify package.json to reflect the correct names.
  4. Run npm start to start the dev-server. Navigate to (localhost:8080)[http://localhost:8080]
  5. Build by running npm run build or npm run build-release

...or

  1. Create two folders: source.
  2. Copy five files: webpack.*.config.js (=3 files), and .gitignore and package.json.
  3. Modify package.json.

Adding loaders or plugins

  • Loaders and plugins that are common to all build configuration should be added to webpack.common.config.js
  • webpack.serve.config.js and webpack.build.config.js contain additional configuration that is specific for the different builds.

Adding support for Typescript

Run on the commandline:

npm install -D typescript awesome-typescript-loader source-map-loader

Add the following object to rules in webpack.common.config:

{
  test: /\.ts$/,
  use: "awesome-typescript-loader"
}

Optionally, add .ts extention to the resolve element so that typescript files are resolved without the .ts extension:

resolve: {
  extensions: ['.ts', '.js']
}

Adding support for React JSX

Run on the commandline:

npm install -D babel-preset-react
npm install -S react react-dom

Add the following object to rules in webpack.common.config:

{
  test: /\.jsx$/,
  exclude: /node_modules/,
  loader: "babel-loader",
  query: {
    presets: ["latest", "react"],
    plugins: ["transform-object-rest-spread"]
  }
},

Also, optionally change the entry point (in webpack.common.config) to "index.jsx"

Adding support for Angular 1.x

Adding the ng-annotate-loader saves you from doubly declaring your angular dependency injections.

Run on the commandline:

npm install -D ng-annotate-loader
npm install -S angular

Exchange the first object in rules in webpack.common.config with:

{
  test: /\.js$/,
  exclude: /node_modules/,
  use: [{
    loader: "ng-annotate-loader"
  },{
    loader: "babel-loader",
    options: {
      presets: ["latest"],
      plugins: ["transform-object-rest-spread"]
    }
  }
}

webpack-application-template's People

Contributors

aeinbu avatar plillevold avatar

Watchers

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