forked from freeboardgames/FreeBoardGames.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
107 lines (96 loc) · 2.77 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const withCSS = require('@zeit/next-css');
const WebpackBar = require('webpackbar');
const withOffline = require('next-offline');
const withOptimizedImages = require('next-optimized-images');
const childProcess = require('child_process');
const withWorkers = require('@zeit/next-workers');
const TSConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const CHANNEL = process.env.CHANNEL || 'development';
const BGIO_SERVER_URL = process.env.BGIO_SERVER_URL;
const BABEL_ENV_IS_PROD = (process.env.BABEL_ENV || 'production') === 'production';
const VERSION = process.env.GIT_REV || getGitHash();
function getGitHash() {
let hash = 'unknown';
try {
hash = childProcess
.execSync('git rev-parse --short HEAD')
.toString()
.trim();
} catch (e) {}
return hash;
}
module.exports = withWorkers(
withOptimizedImages(
withCSS(
withOffline({
cssModules: true,
dontAutoRegisterSw: true,
generateInDevMode: false,
workboxOpts: {
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /^\/.*/,
handler: 'NetworkFirst',
options: {
cacheName: 'offlineCache',
expiration: {
maxEntries: 200,
},
},
},
],
},
poweredByHeader: false,
env: {
CHANNEL,
VERSION,
BGIO_SERVER_URL,
BABEL_ENV_IS_PROD,
GA_TRACKING_CODE: process.env.GA_TRACKING_CODE,
},
webpack: config => {
config.module.rules.push({
test: /\.test.(js|jsx|ts|tsx)$/,
loader: 'ignore-loader',
});
config.module.rules.push({
test: /jest.(config|setup).(js|jsx|ts|tsx)$/,
loader: 'ignore-loader',
});
config.module.rules.push({
test: /\.md$/,
use: 'raw-loader',
});
config.module.rules.push({
test: /\.(webp|svg|mp3|wav)$/,
exclude: /node_modules/,
use: [
{
loader: 'url-loader',
},
],
});
if (process.env.NODE_ENV !== 'development') {
config.plugins.push(
new WebpackBar({
fancy: true,
profile: true,
basic: false,
}),
);
}
if (config.resolve.plugins) {
config.resolve.plugins.push(new TSConfigPathsPlugin());
} else {
config.plugins = [new TSConfigPathsPlugin()];
}
if (!BABEL_ENV_IS_PROD) {
config.optimization.minimizer = [];
}
return config;
},
}),
),
),
);