2021-12-25 15:44:24 +00:00
|
|
|
/*
|
2022-06-18 16:40:28 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-12-25 15:44:24 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2023-05-29 15:32:44 +00:00
|
|
|
const { isMockMode, isTestMode, isProfilingMode, isBuildTime } = require('./src/utils/test-modes')
|
2022-09-16 09:03:29 +00:00
|
|
|
const path = require('path')
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
|
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
2023-06-27 08:43:35 +00:00
|
|
|
enabled: isProfilingMode
|
2022-09-16 09:03:29 +00:00
|
|
|
})
|
2021-12-25 15:44:24 +00:00
|
|
|
|
2022-09-16 09:03:29 +00:00
|
|
|
console.log('Node environment is', process.env.NODE_ENV)
|
2021-12-25 15:44:24 +00:00
|
|
|
|
2022-06-18 16:40:28 +00:00
|
|
|
if (isTestMode) {
|
|
|
|
console.warn(`This build runs in test mode. This means:
|
2023-05-29 15:32:44 +00:00
|
|
|
- No sandboxed iframe
|
2022-09-16 09:03:29 +00:00
|
|
|
- Additional data-attributes for e2e tests added to DOM
|
2023-05-29 15:32:44 +00:00
|
|
|
- Editor and renderer are running on the same origin
|
|
|
|
- No frontend config caching
|
|
|
|
`)
|
2021-12-30 23:05:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 09:03:29 +00:00
|
|
|
if (isMockMode) {
|
2022-06-18 16:40:28 +00:00
|
|
|
console.warn(`This build runs in mock mode. This means:
|
|
|
|
- No real data. All API responses are mocked
|
|
|
|
- No persistent data
|
|
|
|
- No realtime editing
|
2023-05-29 15:32:44 +00:00
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isBuildTime) {
|
|
|
|
console.warn(`This process runs in build mode. During build time this means:
|
|
|
|
- Editor and Renderer base urls are https://example.org
|
|
|
|
- No frontend config will be fetched
|
|
|
|
`)
|
2021-12-25 15:44:24 +00:00
|
|
|
}
|
|
|
|
|
2023-06-27 08:43:35 +00:00
|
|
|
if (isProfilingMode) {
|
|
|
|
console.info('This build contains the bundle analyzer and profiling metrics.')
|
|
|
|
}
|
|
|
|
|
2023-02-05 21:05:02 +00:00
|
|
|
/** @type {import('@svgr/webpack').LoaderOptions} */
|
|
|
|
const svgrConfig = {
|
|
|
|
svgoConfig: {
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
name: 'preset-default',
|
|
|
|
params: {
|
|
|
|
overrides: {
|
|
|
|
removeViewBox: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-25 15:44:24 +00:00
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
const rawNextConfig = {
|
|
|
|
webpack: (config) => {
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.svg$/i,
|
|
|
|
issuer: /\.[jt]sx?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: '@svgr/webpack',
|
2023-02-05 21:05:02 +00:00
|
|
|
options: svgrConfig
|
2021-12-25 15:44:24 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2022-07-30 21:32:19 +00:00
|
|
|
|
|
|
|
const emojiPickerDataModulePath = path.dirname(require.resolve('emoji-picker-element-data/en/emojibase/data.json'))
|
|
|
|
|
2021-12-25 15:44:24 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
2022-07-30 21:32:19 +00:00
|
|
|
from: emojiPickerDataModulePath,
|
2021-12-25 15:44:24 +00:00
|
|
|
to: 'static/js/emoji-data.json'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
)
|
|
|
|
return config
|
|
|
|
},
|
2022-05-09 17:12:47 +00:00
|
|
|
reactStrictMode: false,
|
2021-12-25 15:44:24 +00:00
|
|
|
redirects: () => {
|
|
|
|
return Promise.resolve([
|
|
|
|
{
|
|
|
|
source: '/',
|
2023-09-10 06:54:03 +00:00
|
|
|
destination: '/login',
|
2021-12-25 15:44:24 +00:00
|
|
|
permanent: true
|
|
|
|
}
|
|
|
|
])
|
2022-07-31 18:31:33 +00:00
|
|
|
},
|
2023-08-26 12:26:47 +00:00
|
|
|
output: 'standalone',
|
2023-10-23 19:46:57 +00:00
|
|
|
swcMinify: true,
|
2022-11-02 15:24:45 +00:00
|
|
|
experimental: {
|
|
|
|
outputFileTracingRoot: path.join(__dirname, '../')
|
2023-03-19 17:25:00 +00:00
|
|
|
},
|
|
|
|
productionBrowserSourceMaps: true
|
2021-12-25 15:44:24 +00:00
|
|
|
}
|
|
|
|
const completeNextConfig = withBundleAnalyzer(rawNextConfig)
|
|
|
|
|
|
|
|
module.exports = completeNextConfig
|