-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
85 lines (79 loc) · 2.58 KB
/
Copy pathnext.config.js
File metadata and controls
85 lines (79 loc) · 2.58 KB
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
//@ts-check
const path = require('path');
const { composePlugins, withNx } = require('@nx/next');
const {
buildPractitionerCspDirectives,
normalizeCspHeaderValue,
} = require('./csp-config.js');
const isDev = process.env.NODE_ENV === 'development';
const isProduction = process.env.NODE_ENV === 'production';
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const cspEnforce = process.env.PRACTITIONER_CSP_ENFORCE === 'true';
const practitionerCspHeaderValue = normalizeCspHeaderValue(
buildPractitionerCspDirectives({
supabaseUrl,
isDev,
isProduction,
}),
);
const practitionerCspHeaders = cspEnforce
? [{ key: 'Content-Security-Policy', value: practitionerCspHeaderValue }]
: [
{
key: 'Content-Security-Policy-Report-Only',
value: practitionerCspHeaderValue,
},
];
/**
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
// Use this to set Nx-specific options
// See: https://nx.dev/recipes/next/next-config-setup
nx: {},
transpilePackages: [
'@abstrack/ui',
'@abstrack/ui-web',
'@abstrack/types',
'@abstrack/supabase',
'react-native',
'react-native-web',
],
webpack: (config) => {
const supabaseSrc = path.join(__dirname, '../../packages/supabase/src');
const uiSrc = path.join(__dirname, '../../packages/ui/src');
const uiWebSrc = path.join(__dirname, '../../packages/ui-web/src');
config.resolve.alias = {
...config.resolve.alias,
'react-native$': 'react-native-web',
'@abstrack/types$': path.join(
__dirname,
'../../packages/types/src/index.ts',
),
'@abstrack/supabase$': path.join(supabaseSrc, 'index.ts'),
'@abstrack/supabase/browser': path.join(supabaseSrc, 'browser.ts'),
'@abstrack/supabase/server': path.join(supabaseSrc, 'server.ts'),
'@abstrack/supabase/native': path.join(supabaseSrc, 'native.ts'),
'@abstrack/supabase/admin': path.join(supabaseSrc, 'admin.ts'),
'@abstrack/ui$': path.join(uiSrc, 'index.ts'),
'@abstrack/ui/a11y-web': path.join(uiSrc, 'a11y-web.ts'),
'@abstrack/ui/insights-web': path.join(uiSrc, 'insights-web.ts'),
'@abstrack/ui-web$': path.join(uiWebSrc, 'index.ts'),
'@abstrack/ui-web/sidebar': path.join(uiWebSrc, 'components/sidebar.tsx'),
};
return config;
},
async headers() {
return [
{
source: '/:path*',
headers: practitionerCspHeaders,
},
];
},
};
const plugins = [
// Add more Next.js plugins to this list if needed.
withNx,
];
module.exports = composePlugins(...plugins)(nextConfig);