Node.js Express app boilerplate for a web frontend utilising Semantic UI
This is a Node.js Express app boilerplate that uses Gulp for build task running, Swig for templating and Semantic UI for design bootstrapping. The aim of this boilerplate is to get you off the ground very quickly with a full stack application.
Caveats are that to avoid writing in dependencies on databases or other external services, sessions are stored on the filesystem and there is no authentication (if you want that
npm install passport).
The only exception to this is that the Gulp tasks include a CloudFront publisher to serve static assets from CDN instead of locally, if configured.
Requires Node.js, recommended
6.3.0 or greater
So simple, right?
views/dashboard.html are provided by default as examples of a Semantic UI theme to get you started, along with associated server-side Express routes in
Override or add CSS in
src/css/theme.css and add your own Semantic UI JS calls to
bundle.config.js file Gulp Bundle uses.
To get started, copy the
config/example.config.js file to
config/config.js and fill in the values appropriately for this new file, most are self-explanatory:
requestLogging: false // Logs all requests using Morgansession:secret: 'defaultSecret' // You should change thisname: 'session' // You should change thisgulpBuildMaps: false // Instructs Gulp Bundle to compile source mapsfrontend:useCDN: false // Will use API credentials from `cloudFrontS3` to publish to CDN
Do not commit your API credentials in config.js to a repository - this is bad juju - either symlink to this file and deploy manually, use environment variables or modify and come up with your own secure mechanism for deployment.
Gulp tasks are configured for Semantic UI builds:
gulp watch # watch for Semantic UI source changesgulp clean # Wipe the built dist/ foldergulp build # Build assets to dist/
To make these builds smaller, you can move components listed in
semantic.json into the
disabled section and they will not be incorporated in the build.
You should only need to run
gulp build once unless you are making changes to the Semantic UI site theme, otherwise, run the following:
gulp wipe # Wipe the public/ folder of assetsgulp compile # Minify/concatenate source js/css from src/ into public/gulp optimise # Optimise/compress images from src/images/ into public/
The following commands are combined tasks to build Semantic UI and your own assets:
gulp refresh # Cleans and wipes (like a good 'un)gulp bundle # Builds and compilesgulp publish # Publishes to CDN
The default Gulp action is to refresh, bundle and optimise. Publishing is left as a separate action so you can incorporate it into your deployment process; build and/or publish together you can using the associated scripts:
npm run cdn # gulp publishnpm run gulp # gulp && gulp publish
There is a basic series of tests provided using Mocha, Chai and Should. There is a breaking test to ensure you have a valid configuration file, anything else is down to you as a developer.
Enjoy! Feel free to fork and use for your own applications as the license permits.
The MIT License (MIT) Copyright (c) 2016 clocked0ne 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.