An open API service indexing awesome lists of open source software.

https://github.com/patrickroberts/grunt-webpack-starterkit

A node server template with all the boilerplate for express, dust, socket.io, grunt, webpack, and react.
https://github.com/patrickroberts/grunt-webpack-starterkit

Last synced: 9 months ago
JSON representation

A node server template with all the boilerplate for express, dust, socket.io, grunt, webpack, and react.

Awesome Lists containing this project

README

          

# Grunt-Webpack-Starterkit

With all the power and flexibility of frameworks and task managers, there also comes a lot of boilerplate. This starterkit contains [Express], [Dust], [Socket io], [Grunt], [Webpack], [Babel], and [React]. I will not cover how to use these dependencies since each of them have thorough documentation, but I will show you how this starter kit uses them, and how you can get your server up-and-running in minutes.

### Installation

```sh
$ git clone https://github.com/patrickroberts/grunt-webpack-starterkit.git
$ cd grunt-webpack-starter-kit
$ npm install
$ grunt develop
```

This command runs the server in development mode which, thanks to the power of Grunt, offers some great conveniences:

- Any saved changes to client files in the `src/` folder automatically trigger Webpack to transpile the changes into `client/`, meaning that only a page refresh is required to see the results of your edits immediately.
- Any saved changes to the server files in the `server/` folder or `app.js` file automatically trigger the node process to terminate and restart, allowing you to see the server-side changes immediately.

### Layout

The starter kit contains 5 folders (not including the dependencies):

- `client/` - the transpiled, browser-compliant JS and CSS. __Do not edit this folder, it is autogenerated by `grunt build` and all your changes will be overwritten.__
- `server/` - the server files `require`'d by `app.js`.
- `src/` - the ES6/7/JSX client files. The entry point is `src/app.jsx`, as specified by `webpack.config.js`.
- `tasks/` - the Grunt hook definitions, including the processes for watch and Webpack.
- `views/` - the Dust template files are located here.

### Predefined tasks

```sh
$ grunt develop # runs the server in development mode
$ grunt test # runs tests (this task has been left undefined)
$ grunt # runs the server normally
$ grunt build # generates the transpiled client files
```

### Production

After the client bundle has been generated, none of the `devDependencies` are needed to run the server. In order to run the server in production mode, you must first generate the optimized Webpack bundle by running:

```sh
$ NODE_ENV=production grunt build
```

Then push your server and run the following remotely:

```sh
$ node app
```

### Customization

This starter kit leaves it to you to decide on any database, though it is recommended to place your schema and logic in `server/` so that Grunt can restart the server whenever changes are made in development mode. If that is not suitable then feel free to add your chosen folder name to `tasks/config/supervisor.js`.

You may also use custom CSS, LESS, or SASS. All are supported options by the Webpack configuration of this starter kit. It is recommended to install them as npm modules or to place them in `src/`. If you have a LESS file located at `src/styles/app.less` for example, just add this line to `src/app.jsx`:

```js
require('./styles/app.less');
```

### Options

For scaling Socket io, you may specify a remote [Redis] url via `process.env.REDIS_URL`. Otherwise, be aware that any Socket io state in memory might cause issues when scaling.

### License

The MIT License (MIT)

Copyright (c) 2016 Patrick Roberts

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[Express]:
[Dust]:
[Socket io]:
[Grunt]:
[Webpack]:
[Babel]:
[React]:
[Redis]: