2021-12-25 15:44:24 +00:00
/ *
* SPDX - FileCopyrightText : 2021 The HedgeDoc developers ( see AUTHORS file )
*
* SPDX - License - Identifier : AGPL - 3.0 - only
* /
console . log ( 'Node env is' , process . env . NODE _ENV )
if ( process . env . NEXT _PUBLIC _USE _MOCK _API === 'true' ) {
console . log ( 'Uses mock API' )
} else if ( ! ! process . env . NEXT _PUBLIC _BACKEND _BASE _URL ) {
console . log ( 'Backend base url is' , process . env . NEXT _PUBLIC _BACKEND _BASE _URL )
} else {
console . error ( ` ==============
Neither NEXT _PUBLIC _USE _MOCK _API or NEXT _PUBLIC _BACKEND _BASE _URL is set .
If you want to create a production build we suggest that you set a backend url with NEXT _PUBLIC _BACKEND _BASE _URL .
If you want to create a build that uses the mock api then use build : mock instead or set NEXT _PUBLIC _USE _MOCK _API to "true" .
=== === === === == ` )
process . exit ( 1 )
}
2021-12-30 23:05:02 +00:00
if ( ! ! process . env . NEXT _PUBLIC _IGNORE _IFRAME _ORIGIN _CONFIG ) {
console . warn ( "You have set NEXT_PUBLIC_IGNORE_IFRAME_ORIGIN_CONFIG. This flag is ONLY for testing purposes and will decrease the security of the editor if used in production!" )
}
2021-12-25 15:44:24 +00:00
if ( ! ! process . env . NEXT _PUBLIC _TEST _MODE ) {
2021-12-30 23:05:02 +00:00
console . warn ( 'This build runs in test mode. This means:\n - no sandboxed iframe\n - Additional data-attributes for e2e tests added to DOM' )
2021-12-25 15:44:24 +00:00
}
const path = require ( 'path' )
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' )
const withBundleAnalyzer = require ( '@next/bundle-analyzer' ) ( {
enabled : process . env . ANALYZE === 'true'
} )
/** @type {import('next').NextConfig} */
const rawNextConfig = {
webpack : ( config ) => {
config . module . rules . push ( {
test : /\.svg$/i ,
issuer : /\.[jt]sx?$/ ,
use : [
{
loader : '@svgr/webpack' ,
options : {
svgoConfig : {
plugins : [
{
name : 'preset-default' ,
params : {
overrides : {
removeViewBox : false
}
}
}
]
}
}
}
]
} )
config . plugins . push (
new CopyWebpackPlugin ( {
patterns : [
{ from : path . join ( _ _dirname , 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm' ) , to : 'static/js' } ,
{ from : path . join ( _ _dirname , 'node_modules/@hpcc-js/wasm/dist/expatlib.wasm' ) , to : 'static/js' } ,
{
from : path . join ( _ _dirname , 'node_modules/emoji-picker-element-data/en/emojibase/data.json' ) ,
to : 'static/js/emoji-data.json'
}
]
} )
)
return config
} ,
reactStrictMode : true ,
redirects : ( ) => {
return Promise . resolve ( [
{
source : '/' ,
destination : '/intro' ,
permanent : true
}
] )
}
}
const completeNextConfig = withBundleAnalyzer ( rawNextConfig )
module . exports = completeNextConfig