-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
79 lines (74 loc) · 2.49 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
const {PHASE_PRODUCTION_BUILD} = require("next/constants")
// https://github.com/vercel/next-plugins/tree/master/packages/next-source-maps
const withSourceMaps = require('@zeit/next-source-maps')({
devtool: "hidden-source-map"
})
// https://github.com/getsentry/sentry-webpack-plugin
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
const {
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
SENTRY_ORG,
SENTRY_PROJECT,
SENTRY_AUTH_TOKEN,
NODE_ENV,
} = process.env
const webpack = (config, options) => {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack']
})
if (!options.isServer) {
config.resolve.alias['@sentry/node'] = '@sentry/browser'
}
// https://github.com/vercel/next.js/blob/canary/examples/with-sentry/next.config.js
// Note: This is disabled in development mode.
if (
SENTRY_DSN &&
SENTRY_ORG &&
SENTRY_PROJECT &&
SENTRY_AUTH_TOKEN &&
NODE_ENV === 'production'
) {
config.plugins.push(
new SentryWebpackPlugin({
include: '.next',
ignore: ['node_modules'],
urlPrefix: '~/_next',
release: `karnaugh@${process.env.npm_package_version}_${options.buildId}`,
setCommits: {
repo: 'github.com/JakubKoralewski/karnaugh',
commit: process.env.GIT_HEAD
}
})
)
}
return config
}
module.exports = (phase, {}) => {
//enable both gh pages (/karnaugh) and netlify with (/)
console.log("KARNAUGH_PATH: ", process.env.KARNAUGH_PATH)
console.log("ASSET_PREFIX: ", process.env.ASSET_PREFIX)
let staticFolder = process.env.KARNAUGH_PATH !== undefined ? process.env.KARNAUGH_PATH : '/karnaugh'
console.log("STATIC_FOLDER: ", staticFolder)
const isProductionBuild = phase === PHASE_PRODUCTION_BUILD
let assetPrefix
if (process.env.ASSET_PREFIX !== undefined) {
assetPrefix = process.env.ASSET_PREFIX
} else {
assetPrefix = isProductionBuild ? `https://jcubed.me${staticFolder}/` : ''
}
console.log("isProductionBuild: ", isProductionBuild)
console.log("ASSET_PREFIX: ", assetPrefix)
return withSourceMaps({
webpack,
env: {
prod: isProductionBuild,
// Will be available on both server and client
staticFolder
},
devIndicators: {
autoPrerender: false,
},
assetPrefix
})
}