-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
89 lines (85 loc) · 2.29 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* eslint-disable @typescript-eslint/no-var-requires */
import { resolve, join, dirname } from 'path'
import glob from 'glob'
import { fileURLToPath } from 'url'
import withPlugins from 'next-compose-plugins'
import withPWA from 'next-pwa'
import optimizedImages from 'next-optimized-images'
// const WindiCSSWebpackPlugin = require('windicss-webpack-plugin')
import CompressionWebpackPlugin from 'compression-webpack-plugin'
import PurgeFontawesomePlugin from 'purge-fontawesome/webpack-plugin.js'
const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
const __dirname = dirname(__filename) // get the name of the directory
const isProduction = process.env.NODE_ENV === 'production'
const isNextExportCommand = process.env.NEXT_EXPORT_COMMAND === 'true'
const nextConfigurations = {
experimental: {
// fallbackNodePolyfills: false,
},
images: {
remotePatterns: [
{
protocol: 'https',
port: '',
hostname: 'floatui.com'
},
{
protocol: 'https',
port: '',
hostname: '**.clerk.dev'
},
{
protocol: 'https',
port: '',
hostname: '**.clerk.com'
}
],
...(isNextExportCommand
? {
loader: 'akamai',
unoptimized: true,
path: '/'
}
: {})
},
...(isNextExportCommand
? {
exportPathMap: async () => ({
'/': { page: '/' }
})
}
: {}),
webpack(config) {
config.resolve.alias['@$'] = resolve(__dirname, 'src')
config.resolve.alias['linaria/loader'] = '@linaria/webpack-loader'
if (isProduction) {
config.plugins.push(
new CompressionWebpackPlugin({
test: /\.(js|css|html|svg)$/
})
)
config.plugins.push(
new PurgeFontawesomePlugin({
paths: [glob.sync(join(__dirname, 'src/**/*'), { nodir: true })]
})
)
}
return config
},
...(isProduction
? {
eslint: {
ignoreDuringBuilds: true
},
pwa: {
dest: 'public',
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024
},
swcMinify: true
}
: {})
}
export default withPlugins(
[...(isNextExportCommand ? [optimizedImages] : []), ...(isProduction ? [withPWA] : [])],
nextConfigurations
)