-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
109 lines (103 loc) · 3.17 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
108
109
const composePlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer');
const withOffline = require('next-offline');
const withGraphql = require('next-plugin-graphql');
const Dotenv = require('dotenv-webpack');
const path = require('path');
require('dotenv').config({
path: process.env.NODE_ENV === 'production' ? path.resolve(__dirname, './.env.production') : undefined,
});
const isProd = process.env.NODE_ENV === 'production';
const nextConfig = {
crossOrigin: 'anonymous',
assetPrefix: isProd ? `https:${process.env.CDN_URL}` : '',
// experimental: {
// granularChunks: true,
// },
// assetPrefix: `https:${process.env.CDN_URL}`,
useFileSystemPublicRoutes: false,
webpack(config, options) {
// config.plugins.push(
// new SWPrecacheWebpackPlugin({
// navigateFallback: '/index',
// minify: true,
// staticFileGlobsIgnorePatterns: [/\.next\//],
// staticFileGlobs: [
// '.next/bundles/**/*.{js,json}',
// '.next/static/**/*.{js,css,jpg,jpeg,png,svg,gif}'
// ],
// staticFileGlobsIgnorePatterns: [/_.*\.js$/, /\.map/],
// runtimeCaching: [
// { handler: 'fastest', urlPattern: /[.](jpe?g|png|svg|gif)/ },
// { handler: 'networkFirst', urlPattern: /^https.*(js|css)/ }
// ],
// })
// )
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
// config.plugins.push(
// new BundleAnalyzerPlugin({
// analyzerMode: 'static',
// reportFilename: options.isServer
// ? '../analyze/server.html'
// : './analyze/client.html',
// }),
// );
config.plugins.push(
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true,
}),
);
config.resolve = {
...config.resolve,
...{
alias: {
...config.resolve.alias,
'@lib': path.resolve(__dirname, 'lib'),
'@common': path.resolve(__dirname, 'common'),
'@pages': path.resolve(__dirname, 'pages'),
'google-libphonenumber': path.resolve(__dirname, './libphonenumber-stub.js'),
},
},
};
return config;
},
};
module.exports = composePlugins(
[
// [withOffline, {
// workboxOpts: {
// swDest: 'service-worker.js',
// runtimeCaching: [
// {
// urlPattern: /[.](png|jpg|ico|css)/,
// handler: 'CacheFirst',
// options: {
// cacheName: 'assets-cache',
// cacheableResponse: {
// statuses: [0, 200],
// },
// },
// },
// {
// urlPattern: /^https:\/\/cdn-oss\.soapphoto\.com.*/,
// handler: 'CacheFirst',
// options: {
// cacheName: 'lib-cache',
// },
// },
// {
// urlPattern: /^http.*/,
// handler: 'NetworkFirst',
// options: {
// cacheName: 'http-cache',
// },
// },
// ],
// },
// }],
// [withBundleAnalyzer, { enabled: true }],
withGraphql,
],
nextConfig,
);