-
Notifications
You must be signed in to change notification settings - Fork 288
/
next.config.js
90 lines (84 loc) · 3.25 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
const path = require("path");
const appConfig = require("./config");
module.exports = {
env: {
CANONICAL_URL: appConfig.CANONICAL_URL,
INTERNAL_GRAPHQL_URL: appConfig.INTERNAL_GRAPHQL_URL,
EXTERNAL_GRAPHQL_URL: appConfig.EXTERNAL_GRAPHQL_URL,
SEGMENT_ANALYTICS_SKIP_MINIMIZE: appConfig.SEGMENT_ANALYTICS_SKIP_MINIMIZE,
SEGMENT_ANALYTICS_WRITE_KEY: appConfig.SEGMENT_ANALYTICS_WRITE_KEY,
STRIPE_PUBLIC_API_KEY: appConfig.STRIPE_PUBLIC_API_KEY
},
webpack: (webpackConfig) => {
webpackConfig.module.rules.push({
test: /\.(gql|graphql)$/,
loader: "graphql-tag/loader",
exclude: ["/node_modules/", "/.next/"],
enforce: "pre"
});
webpackConfig.module.rules.push({
test: /\.mjs$/,
type: "javascript/auto"
});
// Duplicate versions of the styled-components package were being loaded, this config removes the duplication.
// It creates an alias to import the es modules version of the styled-components package.
// This is a workaround until the root issue is resolved: https://github.com/webpack/webpack/issues/9329
webpackConfig.resolve.alias["styled-components"] = "styled-components/dist/styled-components.browser.esm.js";
webpackConfig.resolve.alias.components = path.join(__dirname, "components");
webpackConfig.resolve.alias.containers = path.join(__dirname, "containers");
webpackConfig.resolve.alias.context = path.join(__dirname, "context");
webpackConfig.resolve.alias.custom = path.join(__dirname, "custom");
webpackConfig.resolve.alias.hocs = path.join(__dirname, "hocs");
webpackConfig.resolve.alias.hooks = path.join(__dirname, "hooks");
webpackConfig.resolve.alias.lib = path.join(__dirname, "lib");
webpackConfig.resolve.alias.pages = path.join(__dirname, "pages");
webpackConfig.resolve.alias.public = path.join(__dirname, "public");
webpackConfig.resolve.alias.static = path.join(__dirname, "static");
webpackConfig.resolve.alias.serverUtils = path.join(__dirname, "serverUtils");
webpackConfig.resolve.alias.translations = path.join(__dirname, "translations");
webpackConfig.resolve.alias.routes = path.join(__dirname, "routes");
webpackConfig.resolve.alias.utils = path.join(__dirname, "utils");
webpackConfig.resolve.alias.staticUtils = path.join(__dirname, "staticUtils");
webpackConfig.resolve.alias.apiUtils = path.join(__dirname, "apiUtils");
return webpackConfig;
},
experimental: {
redirects() {
return [
{
source: "/graphiql",
destination: appConfig.EXTERNAL_GRAPHQL_URL,
permanent: true
},
{
source: "/graphql-beta",
destination: appConfig.EXTERNAL_GRAPHQL_URL,
permanent: true
},
{
source: "/graphql-alpha",
destination: appConfig.EXTERNAL_GRAPHQL_URL,
permanent: true
},
{
source: "/graphql",
destination: appConfig.EXTERNAL_GRAPHQL_URL,
permanent: true
}
];
},
rewrites() {
return [
// Sitemap
{
source: "/sitemap:subPage?.xml",
destination: "/api/sitemap"
},
{
source: "/",
destination: "/api/detectLanguage"
}
];
}
}
};