-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
61 lines (59 loc) · 1.64 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
/* eslint-disable @typescript-eslint/no-var-requires */
const withSass = require('@zeit/next-sass')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const env = process.env.NODE_ENV
const isProductionDeployment = env === 'production'
module.exports = withSass({
webpack(config, { buildId, dev, isServer, defaultLoaders, dir, },) {
const nextBabelLoader = config.module.rules[0].use
config.module.rules[0].use = [
nextBabelLoader,
{
loader: 'linaria/loader',
options: {
sourceMap: !isProductionDeployment,
},
},
]
config.module.rules.push({
test: /\.css$/,
exclude: /(node_modules)/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// only enable hot in development
hmr: !isProductionDeployment,
// if hmr does not work, this is a forceful method.
reloadAll: true,
},
},
{
loader: 'css-loader',
options: { sourceMap: !isProductionDeployment, },
},
],
},)
if (isServer) {
config.plugins.push(
new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css',
},),
)
}
config.module.rules.push({
test: /\.(graphql|gql)$/,
include: [dir,],
exclude: /node_modules/,
use: [
{
loader: 'graphql-tag/loader',
},
],
},)
config.resolve.extensions = ['.tsx', '.ts', '.js',]
/* eslint-disable @typescript-eslint/camelcase */
config.node = { fs: 'empty', net: 'empty', child_process: 'empty', }
return config
},
},)