-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
87 lines (70 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
const path = require('path');
const dotenv = require('dotenv');
const withCSS = require('@zeit/next-css');
const withTranspileModules = require('next-transpile-modules');
const withBundleAnalyzer = require('@zeit/next-bundle-analyzer');
const ServiceWorkerPlugin = require('serviceworker-webpack-plugin');
const WorkerPlugin = require('worker-plugin');
dotenv.config();
const baseConfig = {
analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE),
analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: 'static',
reportFilename: '../bundles/server.html',
},
browser: {
analyzerMode: 'static',
reportFilename: '../bundles/client.html',
},
},
env: {
HOST: process.env.HOST,
},
publicRuntimeConfig: {
firebase: {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DATABASE_URL,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
},
},
cssModules: true,
cssLoaderOptions: {
modules: true,
camelCase: true,
namedExport: true,
importLoaders: 1,
localIdentName: '[local]__[hash:base64:5]',
},
transpileModules: ['lodash-es'],
workerLoaderOptions: {
publicPath: path.resolve(__dirname, '.next', 'static'),
},
webpack(config, options) {
let { isServer } = options;
config.resolve.alias = {
...config.resolve.alias,
'@self': path.resolve(__dirname),
};
// todo: write your own fucking plugin to generate a service fucking worker
// because i'm fucking tired of going nowhere trying to find a way to make polyfills
// worker-compatible
if (!isServer) {
config.plugins.push(
new WorkerPlugin({
globalObject: false,
}),
new ServiceWorkerPlugin({
entry: path.join(__dirname, 'service-worker.ts'),
filename: 'service-worker.js',
})
);
}
return config;
},
};
module.exports = withBundleAnalyzer(withCSS(withTranspileModules(baseConfig)));