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
|
|
|
|
*/
|
2022-09-16 09:03:29 +00:00
|
|
|
const { isMockMode, isTestMode } = require('./src/utils/test-modes')
|
|
|
|
const path = require('path')
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
|
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
|
|
|
enabled: process.env.ANALYZE === 'true'
|
|
|
|
})
|
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 (isMockMode) {
|
2022-09-16 09:03:29 +00:00
|
|
|
console.log('Use mock API')
|
2022-06-18 16:40:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTestMode) {
|
|
|
|
console.warn(`This build runs in test mode. This means:
|
|
|
|
- no sandboxed iframe
|
2022-09-16 09:03:29 +00:00
|
|
|
- Additional data-attributes for e2e tests added to DOM
|
|
|
|
- Editor and renderer are running on the same origin`)
|
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
|
|
|
|
`)
|
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',
|
|
|
|
options: {
|
|
|
|
svgoConfig: {
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
name: 'preset-default',
|
|
|
|
params: {
|
|
|
|
overrides: {
|
|
|
|
removeViewBox: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
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: '/',
|
|
|
|
destination: '/intro',
|
|
|
|
permanent: true
|
|
|
|
}
|
|
|
|
])
|
2022-07-31 18:31:33 +00:00
|
|
|
},
|
2022-11-02 15:24:45 +00:00
|
|
|
output: 'standalone',
|
2022-12-09 18:35:40 +00:00
|
|
|
swcMinify: false, //Otherwise emoji picker is minified incorrectly
|
2022-11-02 15:24:45 +00:00
|
|
|
experimental: {
|
|
|
|
outputFileTracingRoot: path.join(__dirname, '../')
|
|
|
|
}
|
2021-12-25 15:44:24 +00:00
|
|
|
}
|
|
|
|
const completeNextConfig = withBundleAnalyzer(rawNextConfig)
|
|
|
|
|
|
|
|
module.exports = completeNextConfig
|