express-semantic-ui
Node.js Express app boilerplate for a web frontend utilising Semantic UI
About
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.
Install
Requires Node.js, recommended 6.3.0
or greater
npm install
So simple, right?
Usage
views/index.html
and 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 routes/index.js
.
Override or add CSS in src/css/theme.css
and add your own Semantic UI JS calls to src/js/semantic-ui.js
, or feel free to add additional javascript/CSS files as necessary, just be sure to add them to the 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
session: {
secret: 'defaultSecret',
name: 'session'
},
gulpBuildMaps: false,
frontend: {
useCDN: false
}
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
gulp clean
gulp build
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
gulp compile
gulp optimise
If you are only making frequent javascript and CSS changes outside of Semantic UI, run gulp compile
.
The following commands are combined tasks to build Semantic UI and your own assets:
gulp refresh
gulp bundle
gulp publish
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
npm run gulp
This is enough to get you off the ground running, for full documentation please refer back to Express, Semantic-UI and Gulp documentation separately.
Test
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.
npm test
Enjoy! Feel free to fork and use for your own applications as the license permits.
License
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.