This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
59 lines (55 loc) · 2.3 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
const CopyPlugin = require("copy-webpack-plugin");
const path = require('path');
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
const publicPath = path.join(process.cwd(), 'public');
const externalConfig = require('./externalConfig.json');
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**',
port: '',
pathname: '**',
},
],
},
reactStrictMode: false,
async redirects() {
return [
{
source: '/',
destination: '/client',
permanent: true,
},
{
// Match any path that doesn't start with 'client' or 'admin' and the other
source: `/:path((?!client|admin|${externalConfig.mainMatcher}|${externalConfig.antiRedirectMatcher}).*)`,
destination: '/client/:path*', // Append '/client' to the matched path
permanent: true,
},
]
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => {
// append the CopyPlugin to copy the file to your public dir
config.plugins.push(
new CopyPlugin({
patterns: [
{ from: path.join(nodeModulesPath, 'jquery', 'dist', 'jquery.min.js'), to: path.join(publicPath, 'assets', 'js') },
{ from: path.join(nodeModulesPath, 'bootstrap', 'dist', 'js', 'bootstrap.min.js'), to: path.join(publicPath, 'assets', 'js') },
{ from: path.join(nodeModulesPath, 'slick-carousel', 'slick', 'slick.min.js'), to: path.join(publicPath, 'assets', 'js') },
{ from: path.join(nodeModulesPath, 'nouislider', 'dist', 'nouislider.min.js'), to: path.join(publicPath, 'assets', 'js') },
{ from: path.join(nodeModulesPath, 'jquery-zoom', 'jquery.zoom.min.js'), to: path.join(publicPath, 'assets', 'js') },
],
}),
)
config.module.rules.push({
test: /\.(jpg|png|svg|gif)$/,
type: 'asset/resource',
})
// Important: return the modified config
return config
},
}
module.exports = nextConfig