Giter Club home page Giter Club logo

frontend-boilerplate's Introduction

frontend-boilerplate Build Status

Boilerplate for Java projects with modern JavaScript tooling.

The sample project demonstrates how to combine the following technologies:

  • Maven: The standard build system for Java projects
  • Webpack: The bundler for JavaScript and friends
  • Babel: Babel compiler for writing next generation JavaScript
  • TypeScript: The typed superset of JavaScript
  • Karma: The spectacular Test Runner for JavaScript
  • LESS: CSS with dynamic behavior such as variables, mixins, operations and functions.

Please note that this project doesn't just show how to integrate those technologies. That's the easy part. The most important goal was to create a great development experience.

Maven build

This project uses the frontend-maven-plugin to integrate the JavaScript tooling with Maven. This great plugin does the following things for you:

  • Install node.js and npm locally in the required versions
  • Executes Webpack for transpiling and and merging your JavaScript files
  • Runs the LESS compiler to create your CSS
  • Executes your tests using Karma

All this happens automatically when you run:

$ mvn install

That means that you will get a standard WAR file if you want to.

Development workflow

The project supports different development workflows. Most notably via automatic file watching and the webpack-dev-server.

JavaScript files

The preferred way of transpiling the JavaScript files is to use the webpack-dev-server. The concept is actually very easy. Instead of sending requests to your servlet container, you simply point your browser to the dev server. The dev server will act as a reverse proxy and pass most of the requests though to the servlet container. The only exception to this are the requests for JavaScript files which are instead compiled on demand.

You can start the dev server simply by running:

$ _npm run dev-server

This will start the dev server on port 9999. This means that you have to use http://localhost:9999/ instead of http://localhost:8080/ to access your app.

So if you modify your JavaScript files, you can simply reload the page in the browser to get the new transpiled files.

In this mode Webpack will also generate the required source maps for easy debugging in the browser.

Unit testing

The sample project uses Karma for running JavaScript tests. You can run the test manually by invoking:

$ _npm run test

If you are actively working on the tests, you can also run Karma in watch mode. In this mode the files will be automatically monitored for changes. As soon as you modify any of the JavaScript files, Karma will run all the tests which is usually very fast.

You can execute Karma in watch mode with:

$ _npm run watch:karma

Please note the Karma is configured to use PhantomJS in standard mode and Google Chrome in watch mode. If you want to use PhantomJS in watch mode, just remove the --chrome option from the corresponding script entry in package.json.

LESS files

You can watch your less files for modifications and automatically rebuild the CSS files by running:

$ _npm run watch:css

The transpiling is really fast. The file are copied to the correct folders so that reloading the page in your browser should show the results immediately.

frontend-boilerplate's People

Contributors

chkal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

frontend-boilerplate's Issues

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.