-
Notifications
You must be signed in to change notification settings - Fork 7
/
next.config.js
107 lines (90 loc) · 2.35 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Dependencies
const path = require('path')
// Extensions
const withImages = require('next-images')
// Constants
const DEFAULT = process.env.NEXT_PUBLIC_DEFAULT_LOCALE
const LOCALES = process.env.NEXT_PUBLIC_SUPPORTED_LOCALES.split('|')
// Configuration
const config = {
// Locales Options
i18n: {
locales: LOCALES,
localeDetection: true,
defaultLocale: DEFAULT,
},
// Images Options
images: {
deviceSizes: [320, 450, 600, 768, 1024, 1340, 1440, 1920],
disableStaticImages: true,
},
// SASS Options
sassOptions: {
includePaths: [path.join(__dirname), path.join(__dirname, 'src')],
},
// Extend Webpack Configuration
webpack(_config, { webpack }) {
// Variables
const name = '[name].[hash].[ext]'
// Loaders
const rules = [
// Medias
{
test: /\.(mp3|wav|ogg|mp4|webm|ogv)$/,
use: {
loader: 'file-loader',
options: {
name,
outputPath: 'static/media/',
publicPath: '/_next/static/media',
},
},
},
// Shaders
{
test: /\.(glsl|frag|vert)$/,
exclude: /node_modules/,
use: [
'raw-loader',
{
loader: 'glslify-loader',
options: {
transform: ['glslify-import'],
},
},
],
},
]
// Plugins
const plugins = []
// Add Loaders
/* eslint-disable-next-line */
for (const rule of rules) {
_config.module.rules.push(rule)
}
// Add Plugins
/* eslint-disable-next-line */
for (const plugin of plugins) {
_config.plugins.push(plugin)
}
// Resolve Extensions
_config.resolve.extensions.push('.css')
_config.resolve.extensions.push('.sass')
_config.resolve.extensions.push('.scss')
_config.resolve.extensions.push('.json')
// Resolve Modules
_config.resolve.modules.push('.')
_config.resolve.modules.push('src')
// Result HMR Warnings
// See: https://github.com/vercel/next.js/issues/19865#issuecomment-810738415
const major = webpack.version.split('.')[0]
if (major === '5') {
_config.output.hotUpdateMainFilename =
'static/webpack/[fullhash].[runtime].hot-update.json'
}
// Return Configuration
return _config
},
}
// Export Configuration
module.exports = withImages(config)