-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
83 lines (73 loc) · 2.07 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
require('dotenv').config();
const path = require('path');
const Dotenv = require('dotenv-webpack');
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')(['imask', 'react-imask', 'client-zip', 'react-sortablejs']);
const withCSS = require('@zeit/next-css');
const nextConfig = {
poweredByHeader: false,
webpack: (config, options) => {
const { isServer } = options;
if (!isServer) {
// eslint-disable-next-line no-param-reassign
config.node = {
net: 'empty',
tls: 'empty',
};
}
// eslint-disable-next-line no-param-reassign
config.plugins = config.plugins || [];
config.plugins.push(
// Read the .env file
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true,
}),
);
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
});
config.module.rules.push({
test: /\.(woff(2)?|otf|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
fallback: 'file-loader',
publicPath: `/_next/static/chunks/fonts/`,
outputPath: `${isServer ? '../' : ''}static/chunks/fonts/`,
name: '[name]-[hash].[ext]',
},
},
],
});
config.module.rules.push({
test: /\.svg$/,
use: [
'babel-loader',
{
loader: 'react-svg-loader',
options: {
jsx: true,
svgo: {
plugins: [
{
removeViewBox: false,
},
],
},
},
},
],
});
// TODO: remove when using only typescript
// allow using all file extensions while we transition into full typescript
// eslint-disable-next-line no-param-reassign
config.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx'];
return config;
},
};
module.exports = withPlugins([withCSS, withTM], nextConfig);