Skip to content

Commit

Permalink
Merge pull request #656 from Amsterdam/release/v1.6.0
Browse files Browse the repository at this point in the history
Release/v1.6.0
  • Loading branch information
janjaap authored Mar 4, 2020
2 parents a0f7d2d + ab21056 commit 3f37880
Show file tree
Hide file tree
Showing 111 changed files with 13,881 additions and 1,977 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ stats.json
.DS_Store
npm-debug.log
.idea
.nvmrc
55 changes: 48 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,69 @@ See https://github.com/Amsterdam/react-boilerplate.git for more information on t
## Requirements

- npm >= 6.11
- node >= v10.16
- node >= v10.16 < v12.0

This project relies on the[ `leaflet-headless`](https://www.npmjs.com/package/leaflet-headless) package. On OSX, you'll need to have [`cairo`](https://formulae.brew.sh/formula/cairo), [`pango`](https://formulae.brew.sh/formula/pango) and [`cmake`](https://formulae.brew.sh/formula/cmake) installed.

## Installations
## Node versions

If you are running Node 12 or later you could use *nvm* (we need an older version of Node until we upgrade leaflet)

Install *nvm* from source or with your preferred package manager.

Modify your shell startup file and add the following line to load the *nvm* script when you login:

source /usr/share/nvm/init-nvm.sh

Install a specific node version with *nvm* and make it the active node version:

nvm install 11.15.0
nvm use 11.15.0

If you would like to use your system *Node* version as default, you could alias it to the default🐚

nvm alias default system

To specify the Node version for your project you could create an **.nvmrc** file, for example:

echo 11.15.0 > ~/projects/signals-frontend/.nvmrc
npm start

## Installation

- npm install

## Configure IPs
Depending of how many api / auth / maps / components / auth
you have running configure the ips in.

Depending of how many api / auth / maps / components you have running configure the ip addresses in:

- environment.conf.json

## Development

- npm start
- The SPA will open at http://localhost:3001/
The SPA will run over HTTP on `localhost` at port `3001`. The port can be configured by setting the environment variable `PORT`.

npm start

PORT=8000 npm start

Do note that the application uses an external authentication service that does not accept any port. The whitelisted ports are `3000` and `3001`

### HTTPS

The application's production build uses a [serviceworker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) that is configured through the Webpack Offline plugin (see [webpack config](./internals/webpack/webpack.prod.babel.js)) and is installed in [app.js](./src/app.js).

To run the application with the production code and have the serviceworker available, the site needs to be run over HTTPS. This can be accomplished by running

HTTPS=true npm run start:prod

## Testing

- npm run test
By default, the unit test generates a coverage report (thresholds are set in [jest.config.js](./jest.config.js)).

Running all tests and generate the coverage report:

npm test

## Thanks to
<a href="http://browserstack.com/"><img src="src/images/browserstack-logo-600x315.png" height="130" alt="BrowserStack Logo" /></a>
3 changes: 2 additions & 1 deletion internals/testing/test-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import 'jest-localstorage-mock';

import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import fetchMock from 'jest-fetch-mock';

global.fetch = require('jest-fetch-mock');
fetchMock.enableMocks();

// React 16 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() });
Expand Down
9 changes: 6 additions & 3 deletions internals/webpack/webpack.base.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;

const devMode = process.env.NODE_ENV !== 'production';

Expand Down Expand Up @@ -114,7 +115,7 @@ module.exports = options => ({
},
],
},
plugins: options.plugins.concat([
plugins: [
new CopyWebpackPlugin([
{
from: './node_modules/amsterdam-amaps/dist/nlmaps/dist/assets',
Expand All @@ -139,7 +140,9 @@ module.exports = options => ({
}),

process.env.ANALYZE && new BundleAnalyzerPlugin(),
]).filter(Boolean),
]
.concat(options.plugins)
.filter(Boolean),
resolve: {
modules: ['node_modules', 'src'],
extensions: ['.js', '.jsx', '.react.js'],
Expand Down
47 changes: 25 additions & 22 deletions internals/webpack/webpack.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,28 +166,6 @@ module.exports = require('./webpack.base.babel')({
inject: true,
}),

// Put it in the end to capture all the HtmlWebpackPlugin's
// assets manipulations and do leak its manipulations to HtmlWebpackPlugin
new OfflinePlugin({
relativePaths: false,
publicPath: '/',
appShell: '/',

excludes: ['version.txt'],

caches: {
main: [':rest:'],

// All chunks marked as `additional`, loaded after main section
// and do not prevent SW to install. Change to `optional` if
// do not want them to be preloaded at all (cached only when first loaded)
additional: ['*.chunk.js'],
},

// Removes warning for about `additional` section usage
safeToUseOptionalCaches: true,
}),

new WebpackPwaManifest({
name: 'Signalen Informatievoorziening Amsterdam',
short_name: 'SIA',
Expand Down Expand Up @@ -217,6 +195,31 @@ module.exports = require('./webpack.base.babel')({
hashDigest: 'hex',
hashDigestLength: 20,
}),

// Put it in the end to capture all the HtmlWebpackPlugin's
// assets manipulations and do leak its manipulations to HtmlWebpackPlugin
new OfflinePlugin({
ServiceWorker: {
events: true,
},
relativePaths: false,
publicPath: '/',
appShell: '/',

excludes: ['version.txt', 'sw.js'],

caches: {
main: [':rest:'],

// All chunks marked as `additional`, loaded after main section
// and do not prevent SW to install. Change to `optional` if
// do not want them to be preloaded at all (cached only when first loaded)
additional: ['*.chunk.js'],
},

// Removes warning for about `additional` section usage
safeToUseOptionalCaches: true,
}),
],

performance: {
Expand Down
Loading

0 comments on commit 3f37880

Please sign in to comment.