-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnext.config.js
92 lines (87 loc) · 2.46 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const withCSS = require('@zeit/next-css');
const NextWorkboxPlugin = require('next-workbox-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const path = require('path');
module.exports = withCSS({
webpack(config, { isServer, buildId, dev }) {
// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty',
};
// if (!isServer) {
// config.module.rules.find(({ test }) => test.test('style.css')).use.push({
// loader: 'css-purify-webpack-loader',
// options: {
// includes: ['./pages/*.js', './components/*.js'],
// },
// });
// }
const workboxOptions = {
clientsClaim: true,
skipWaiting: true,
globPatterns: ['.next/static/*', '.next/static/commons/*'],
modifyUrlPrefix: {
'.next': '/_next',
},
runtimeCaching: [
{
urlPattern: '/',
handler: 'networkFirst',
options: {
cacheName: 'html-cache',
},
},
{
urlPattern: /.*\.(?:png|jpg|jpeg|svg|gif)/,
handler: 'cacheFirst',
options: {
cacheName: 'image-cache',
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
};
if (!isServer && !dev) {
config.plugins.push(
new NextWorkboxPlugin({
buildId,
...workboxOptions,
}),
new WebpackPwaManifest({
filename: 'static/manifest.json',
name: 'Request Yo Racks',
short_name: 'RYR',
description: 'Request a bike rack in 3 simple steps.',
background_color: '#ffffff',
theme_color: '#B35C22',
display: 'standalone',
orientation: 'portrait',
fingerprints: false,
inject: false,
start_url: '/',
ios: {
'apple-mobile-web-app-title': 'Request Yo Racks',
'apple-mobile-web-app-status-bar-style': '#B35C22',
},
icons: [
{
src: path.resolve('static/favicon.ico'),
sizes: [96, 128, 256, 384],
destination: '/static',
},
{
src: path.resolve('static/manifest/icon.png'),
sizes: [192, 512],
destination: '/static',
},
],
includeDirectory: true,
publicPath: '..',
})
);
}
return config;
},
});