2021-12-25 10:44:24 -05:00
|
|
|
/*
|
2022-06-18 12:40:28 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-12-25 10:44:24 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2022-09-16 05:03:29 -04: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 10:44:24 -05:00
|
|
|
|
2022-09-16 05:03:29 -04:00
|
|
|
console.log('Node environment is', process.env.NODE_ENV)
|
2021-12-25 10:44:24 -05:00
|
|
|
|
2022-06-18 12:40:28 -04:00
|
|
|
if (isMockMode) {
|
2022-09-16 05:03:29 -04:00
|
|
|
console.log('Use mock API')
|
2022-06-18 12:40:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTestMode) {
|
|
|
|
console.warn(`This build runs in test mode. This means:
|
|
|
|
- no sandboxed iframe
|
2022-09-16 05:03:29 -04:00
|
|
|
- Additional data-attributes for e2e tests added to DOM
|
|
|
|
- Editor and renderer are running on the same origin`)
|
2021-12-30 18:05:02 -05:00
|
|
|
}
|
|
|
|
|
2022-09-16 05:03:29 -04:00
|
|
|
if (isMockMode) {
|
2022-06-18 12:40:28 -04: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 10:44:24 -05:00
|
|
|
}
|
|
|
|
|
2023-02-05 16:05:02 -05:00
|
|
|
/** @type {import('@svgr/webpack').LoaderOptions} */
|
|
|
|
const svgrConfig = {
|
|
|
|
svgoConfig: {
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
name: 'preset-default',
|
|
|
|
params: {
|
|
|
|
overrides: {
|
|
|
|
removeViewBox: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:44:24 -05:00
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
const rawNextConfig = {
|
|
|
|
webpack: (config) => {
|
2023-02-05 16:05:02 -05:00
|
|
|
|
2021-12-25 10:44:24 -05:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.svg$/i,
|
|
|
|
issuer: /\.[jt]sx?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: '@svgr/webpack',
|
2023-02-05 16:05:02 -05:00
|
|
|
options: svgrConfig
|
2021-12-25 10:44:24 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
const emojiPickerDataModulePath = path.dirname(require.resolve('emoji-picker-element-data/en/emojibase/data.json'))
|
|
|
|
|
2021-12-25 10:44:24 -05:00
|
|
|
config.plugins.push(
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
2022-07-30 17:32:19 -04:00
|
|
|
from: emojiPickerDataModulePath,
|
2021-12-25 10:44:24 -05:00
|
|
|
to: 'static/js/emoji-data.json'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
)
|
|
|
|
return config
|
|
|
|
},
|
2022-05-09 13:12:47 -04:00
|
|
|
reactStrictMode: false,
|
2021-12-25 10:44:24 -05:00
|
|
|
redirects: () => {
|
|
|
|
return Promise.resolve([
|
|
|
|
{
|
|
|
|
source: '/',
|
|
|
|
destination: '/intro',
|
|
|
|
permanent: true
|
|
|
|
}
|
|
|
|
])
|
2022-07-31 14:31:33 -04:00
|
|
|
},
|
2022-11-02 11:24:45 -04:00
|
|
|
output: 'standalone',
|
2022-12-09 13:35:40 -05:00
|
|
|
swcMinify: false, //Otherwise emoji picker is minified incorrectly
|
2022-11-02 11:24:45 -04:00
|
|
|
experimental: {
|
|
|
|
outputFileTracingRoot: path.join(__dirname, '../')
|
2023-03-19 13:25:00 -04:00
|
|
|
},
|
|
|
|
productionBrowserSourceMaps: true
|
2021-12-25 10:44:24 -05:00
|
|
|
}
|
|
|
|
const completeNextConfig = withBundleAnalyzer(rawNextConfig)
|
|
|
|
|
|
|
|
module.exports = completeNextConfig
|