forked from kausaltech/kausal-watch-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
126 lines (117 loc) · 3.8 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* eslint-disable no-restricted-syntax */
const webpack = require('webpack');
const { secrets } = require('docker-secret');
const { withSentryConfig } = require('@sentry/nextjs');
const { i18n, SUPPORTED_LANGUAGES } = require('./next-i18next.config');
const path = require('path');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const sentryAuthToken =
secrets.SENTRY_AUTH_TOKEN || process.env.SENTRY_AUTH_TOKEN;
function initializeThemes() {
const destPath = path.join(__dirname, 'public', 'static', 'themes');
const {
generateThemeSymlinks: generateThemeSymlinksPublic,
} = require('@kausal/themes/setup.cjs');
generateThemeSymlinksPublic(destPath, { verbose: false });
try {
const {
generateThemeSymlinks: generateThemeSymlinksPrivate,
} = require('@kausal/themes-private/setup.cjs');
generateThemeSymlinksPrivate(destPath, { verbose: false });
} catch (error) {
console.error(error);
}
}
initializeThemes();
let config = {
i18n,
env: {
SENTRY_DSN: process.env.SENTRY_DSN,
SENTRY_TRACE_SAMPLE_RATE: process.env.SENTRY_TRACE_SAMPLE_RATE || '1.0',
},
sentry: {
// If SENTRY_AUTH_TOKEN is not set, disable uploading source maps to Sentry
disableServerWebpackPlugin: !sentryAuthToken,
disableClientWebpackPlugin: !sentryAuthToken,
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
productionBrowserSourceMaps: true,
compiler: {
// Enables the styled-components SWC transform
styledComponents: true,
},
swcMinify: true,
experimental: {
modularizeImports: {
lodash: {
transform: 'lodash/{{member}}',
},
},
},
async rewrites() {
const rewrites = [
{ source: '/favicon.ico', destination: '/public/static/favicon.ico' },
];
return rewrites;
},
publicRuntimeConfig: {
// Will be available on both server and client
aplansApiBaseURL:
process.env.APLANS_API_BASE_URL || 'https://api.watch.kausal.tech/v1',
// the default value for PLAN_IDENTIFIER is set below in webpack config
defaultPlanIdentifier: process.env.PLAN_IDENTIFIER,
defaultThemeIdentifier: process.env.THEME_IDENTIFIER,
deploymentType: process.env.DEPLOYMENT_TYPE || 'development',
matomoURL: process.env.MATOMO_URL,
matomoSiteId: process.env.MATOMO_SITE_ID,
sentryDsn: process.env.SENTRY_DSN,
supportedLanguages: SUPPORTED_LANGUAGES,
forceFeatures: process.env.FORCE_FEATURES?.split(','),
},
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["cfg"] }] */
webpack(cfg, options) {
const { isServer, buildId, dev } = options;
if (!isServer) {
cfg.resolve.alias['@sentry/node'] = '@sentry/browser';
cfg.resolve.alias['next-i18next/serverSideTranslations'] = false;
cfg.resolve.alias['./next-i18next.config'] = false;
cfg.resolve.symlinks = true;
}
cfg.plugins.push(
new webpack.EnvironmentPlugin({
PLAN_IDENTIFIER: '',
THEME_IDENTIFIER: '',
DISABLE_THEME_CACHE: '',
MATOMO_URL: '',
MATOMO_SITE_ID: '',
SYNC_THEME: '',
FORCE_SENTRY_SEND: '',
})
);
cfg.plugins.push(
new webpack.DefinePlugin({
__SENTRY_DEBUG__: false,
})
);
cfg.experiments = { ...cfg.experiments, topLevelAwait: true };
return cfg;
},
};
const sentryWebpackOpts = {
authToken: sentryAuthToken,
};
config = withSentryConfig(withBundleAnalyzer(config), sentryWebpackOpts);
module.exports = config;