-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
130 lines (123 loc) · 3.31 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const withPlugins = require("next-compose-plugins")
const withCSS = require("@zeit/next-css")
//const withPurgeCss = require('next-purgecss')
const withFonts = require("next-fonts")
const webpack = require("webpack")
const withTM = require("next-transpile-modules")
const optimizedImages = require("next-optimized-images")
require("dotenv").config()
const nextConfig = {
webpack: (config, { isServer }) => {
config.node = {
fs: "empty",
}
const originalEntry = config.entry
config.entry = async () => {
const entries = await originalEntry()
if (
entries["server.js"] &&
!entries["server.js"].includes("./client/polyfills.js")
) {
entries["server.js"].unshift("./client/polyfills.js")
}
return entries
}
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
})
config.module.rules.push({
test: /\.jpe?g$/,
loaders: [
{
loader: "lqip-loader",
options: {
path: "/public", // your image going to be in media folder in the output dir
name: "[name].[ext]", // you can use [hash].[ext] too if you wish,
base64: true, // default: true, gives the base64 encoded image
palette: false, // default: false, gives the dominant colours palette
},
},
],
})
config.plugins.push(new webpack.EnvironmentPlugin(process.env))
return config
},
}
module.exports = withPlugins(
[
[withCSS],
// [withPurgeCss, {
// purgeCssEnabled: ({ dev, isServer }) => (!dev && !isServer), // Only enable PurgeCSS for client-side production builds
// }],
[withFonts],
[
withTM,
{
transpileModules: [
"@apollo/react-hooks",
"@emotion/core",
"@emotion/styled",
"@svgr/webpack",
"@tryghost/content-api",
"apollo-boost",
"apollo-cache-inmemory",
"apollo-client",
"apollo-link",
"apollo-link-rest",
"chart.js",
"chartjs-plugin-piechart-outlabels",
"classnames",
"contentful",
"cookie",
"cookie-parser",
"dotenv",
"downshift",
"fetch-headers",
"graphql",
"graphql-anywhere",
"graphql-tag",
"highcharts",
"highcharts-pattern-fill",
"highcharts-react-official",
"isomorphic-fetch",
"isomorphic-unfetch",
"js-cookie",
"json-csv",
"moment",
"moment-timezone",
"next-cookies",
"next-routes",
"node-fetch",
"qs",
"react-apollo-hooks",
"react-chartjs-2",
"react-html-parser",
"react-paginate",
"react-popper",
"react-scrollbars-custom",
// "react-select",
// "react-slick",
"react-spinners",
// "react-sticky",
"react-table",
"react-tabs",
"react-tooltip",
"save",
"strip-ansi",
"scheduler",
"tinycolor2",
"underscore",
],
},
],
[
optimizedImages,
{
handleImages: ["jpeg", "png", "webp", "gif"],
optimizeImagesInDev: true,
},
],
],
nextConfig
)