|
| 1 | +/* eslint-disable @typescript-eslint/no-var-requires */ |
| 2 | +/* eslint-disable no-undef */ |
1 | 3 | // Config got from Renaud ROHLINGER <https://twitter.com/onirenaud
|
2 | 4 |
|
3 | 5 | /** @type {import('next').NextConfig} */
|
4 |
| -const plugins = require("next-compose-plugins"); |
5 |
| -const withBundleAnalyzer = require("@next/bundle-analyzer")({ |
6 |
| - enabled: process.env.ANALYZE === "true", |
7 |
| -}); |
| 6 | +const plugins = require('next-compose-plugins') |
| 7 | +const withBundleAnalyzer = require('@next/bundle-analyzer')({ |
| 8 | + enabled: process.env.ANALYZE === 'true' |
| 9 | +}) |
8 | 10 |
|
9 |
| -const nextConfig = { |
10 |
| - reactStrictMode: true, |
11 |
| - compiler: { |
12 |
| - // ssr and displayName are configured by default |
13 |
| - styledComponents: true, |
14 |
| - }, |
15 |
| - webpack(config, { isServer }) { |
16 |
| - // audio support |
17 |
| - config.module.rules.push({ |
18 |
| - test: /\.(ogg|mp3|wav|mpe?g)$/i, |
19 |
| - exclude: config.exclude, |
20 |
| - use: [ |
21 |
| - { |
22 |
| - loader: require.resolve("url-loader"), |
23 |
| - options: { |
24 |
| - limit: config.inlineImageLimit, |
25 |
| - fallback: require.resolve("file-loader"), |
26 |
| - publicPath: `${config.assetPrefix}/_next/static/images/`, |
27 |
| - outputPath: `${isServer ? "../" : ""}static/images/`, |
28 |
| - name: "[name]-[hash].[ext]", |
29 |
| - esModule: config.esModule || false, |
30 |
| - }, |
31 |
| - }, |
32 |
| - ], |
33 |
| - }); |
| 11 | +const nextTranslate = require('next-translate-plugin') |
34 | 12 |
|
35 |
| - // shader support |
36 |
| - config.module.rules.push({ |
37 |
| - test: /\.(glsl|vs|fs|vert|frag)$/, |
38 |
| - exclude: /node_modules/, |
39 |
| - use: ["raw-loader", "glslify-loader"], |
40 |
| - }); |
| 13 | +const nextConfig = { |
| 14 | + reactStrictMode: true, |
| 15 | + compiler: { |
| 16 | + // ssr and displayName are configured by default |
| 17 | + styledComponents: true |
| 18 | + }, |
| 19 | + ...nextTranslate({ |
| 20 | + webpack: (config, { isServer }) => { |
| 21 | + // audio support |
| 22 | + config.module.rules.push({ |
| 23 | + test: /\.(ogg|mp3|wav|mpe?g)$/i, |
| 24 | + exclude: config.exclude, |
| 25 | + use: [ |
| 26 | + { |
| 27 | + loader: require.resolve('url-loader'), |
| 28 | + options: { |
| 29 | + limit: config.inlineImageLimit, |
| 30 | + fallback: require.resolve('file-loader'), |
| 31 | + publicPath: `${config.assetPrefix}/_next/static/images/`, |
| 32 | + outputPath: `${isServer ? '../' : ''}static/images/`, |
| 33 | + name: '[name]-[hash].[ext]', |
| 34 | + esModule: config.esModule || false |
| 35 | + } |
| 36 | + } |
| 37 | + ] |
| 38 | + }) |
41 | 39 |
|
42 |
| - return config; |
43 |
| - }, |
44 |
| -}; |
| 40 | + // shader support |
| 41 | + config.module.rules.push({ |
| 42 | + test: /\.(glsl|vs|fs|vert|frag)$/, |
| 43 | + exclude: /node_modules/, |
| 44 | + use: ['raw-loader', 'glslify-loader'] |
| 45 | + }) |
45 | 46 |
|
46 |
| -// manage i18n |
47 |
| -if (process.env.EXPORT !== "true") { |
48 |
| - nextConfig.i18n = { |
49 |
| - locales: ["en-US"], |
50 |
| - defaultLocale: "en-US", |
51 |
| - }; |
| 47 | + return config |
| 48 | + } |
| 49 | + }) |
52 | 50 | }
|
53 | 51 |
|
54 | 52 | module.exports = plugins(
|
| 53 | + [ |
55 | 54 | [
|
56 |
| - [ |
| 55 | + { |
| 56 | + workboxOpts: { |
| 57 | + swDest: process.env.NEXT_EXPORT |
| 58 | + ? 'service-worker.js' |
| 59 | + : 'static/service-worker.js', |
| 60 | + runtimeCaching: [ |
| 61 | + { |
| 62 | + urlPattern: /^https?.*/, |
| 63 | + handler: 'NetworkFirst', |
| 64 | + options: { |
| 65 | + cacheName: 'offlineCache', |
| 66 | + expiration: { |
| 67 | + maxEntries: 200 |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + ] |
| 72 | + }, |
| 73 | + async rewrites () { |
| 74 | + return [ |
57 | 75 | {
|
58 |
| - workboxOpts: { |
59 |
| - swDest: process.env.NEXT_EXPORT |
60 |
| - ? "service-worker.js" |
61 |
| - : "static/service-worker.js", |
62 |
| - runtimeCaching: [ |
63 |
| - { |
64 |
| - urlPattern: /^https?.*/, |
65 |
| - handler: "NetworkFirst", |
66 |
| - options: { |
67 |
| - cacheName: "offlineCache", |
68 |
| - expiration: { |
69 |
| - maxEntries: 200, |
70 |
| - }, |
71 |
| - }, |
72 |
| - }, |
73 |
| - ], |
74 |
| - }, |
75 |
| - async rewrites() { |
76 |
| - return [ |
77 |
| - { |
78 |
| - source: "/service-worker.js", |
79 |
| - destination: "/_next/static/service-worker.js", |
80 |
| - }, |
81 |
| - ]; |
82 |
| - }, |
83 |
| - }, |
84 |
| - ], |
85 |
| - withBundleAnalyzer, |
| 76 | + source: '/service-worker.js', |
| 77 | + destination: '/_next/static/service-worker.js' |
| 78 | + } |
| 79 | + ] |
| 80 | + } |
| 81 | + } |
86 | 82 | ],
|
87 |
| - nextConfig |
88 |
| -); |
89 |
| - |
90 |
| -// const nextConfig = { |
91 |
| -// reactStrictMode: true, |
92 |
| -// compiler: { |
93 |
| -// // ssr and displayName are configured by default |
94 |
| -// styledComponents: true, |
95 |
| -// }, |
96 |
| -// }; |
97 |
| - |
98 |
| -// module.exports = nextConfig |
| 83 | + withBundleAnalyzer |
| 84 | + ], |
| 85 | + nextConfig |
| 86 | +) |
0 commit comments