-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
92 lines (80 loc) · 2.21 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
const webpack = (config, options) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
const MomentLocalesPlugin = require('moment-locales-webpack-plugin')
/**
* Fix locales issue
* https://github.com/moment/moment/issues/2517#issuecomment-620674018
*/
config.plugins.push(
new MomentLocalesPlugin({
localesToKeep: ['ru', 'en'],
})
)
config.module.rules.push({
test: /\.pdf/,
use: [
options.defaultLoaders.babel,
{
loader: 'file-loader',
options: {
limit: 1000,
name: '[name]_[hash].[ext]',
publicPath: `/_next/static/pdf`,
outputPath: 'static/pdf',
},
},
],
})
// https://github.com/vercel/next.js/issues/11164#issuecomment-602204795
config.module.rules.push({
// test: /\.(png|jpe?g|gif)$/i,
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
// loader: 'url-loader',
// issuer: {
// // nextjs already handles url() in css/sass/scss files
// test: /\.\w+(?<!(s?c|sa)ss)$/i,
// },
use: [
{
loader: 'url-loader',
options: {
context: 'src',
name() {
if (process.env.NODE_ENV === 'development') {
return '[path][name].[ext]'
}
return '[contenthash].[ext]'
},
publicPath: `/_next/static/media`,
outputPath: 'static/media',
limit: 1000,
},
},
],
})
// Object.assign(config, {
// // https://nextjs.org/docs/api-reference/next.config.js/disabling-etag-generation
// generateEtags: false,
// });
return config
// Important: return the modified config
// return {
// ...config,
// // https://nextjs.org/docs/api-reference/next.config.js/disabling-etag-generation
// generateEtags: false,
// }
}
module.exports = (phase, defaultConfig) => {
// if(phase === "phase-development-server") {
if (phase !== 'phase-production-server') {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
return withBundleAnalyzer({
webpack,
})
}
// else
return defaultConfig
}