-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
68 lines (62 loc) · 1.73 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
const { VanillaExtractPlugin } = require("@vanilla-extract/webpack-plugin");
const {
getGlobalCssLoader,
} = require("next/dist/build/webpack/config/blocks/css/loaders");
const { lazyPostCSS } = require("next/dist/build/webpack/config/blocks/css");
// @ts-check
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
experimental: {
appDir: true,
},
compiler: {
relay: {
src: "./src/",
schema: "../api/orbt.graphql",
language: "typescript",
artifactDirectory: "./src/__generated__",
},
},
output: "standalone",
webpack: (config, { isServer, dev, dir, supportedBrowsers }) => {
config.module.rules.unshift({
test: /\.svg$/,
issuer: /\.[jt]sx?$/,
use: [{ loader: "@svgr/webpack", options: { typescript: true } }],
});
const cssRules = config.module.rules.find(
(rule) =>
Array.isArray(rule.oneOf) &&
rule.oneOf.some(
({ test }) =>
typeof test === "object" &&
typeof test.test === "function" &&
test.test("filename.css")
)
).oneOf;
cssRules.unshift({
test: /\.vanilla\.css$/i,
sideEffects: true,
use: getGlobalCssLoader(
{
assetPrefix: config.assetPrefix,
isClient: !isServer,
isServer,
isDevelopment: dev,
future: nextConfig.future || {},
experimental: nextConfig.experimental || {},
hasAppDir: true,
},
() => lazyPostCSS(dir, supportedBrowsers),
[]
),
});
config.plugins.push(
new VanillaExtractPlugin({ outputCss: !isServer, identifiers: "short" })
);
return config;
},
};
module.exports = nextConfig;