-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
70 lines (62 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
62
63
64
65
66
67
68
69
70
const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin');
const { getGlobalCssLoader } = require('next/dist/build/webpack/config/blocks/css/loaders');
const MiniCssExtractPlugin = require('next/dist/build/webpack/plugins/mini-css-extract-plugin/src').default;
module.exports = {
future: {
webpack5: true,
},
webpack: (config, { dev, isServer, ...options }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.resolve.fallback = {
fs: false,
path: require.resolve('path-browserify'),
};
}
// --- vanilla-extract config ---
// based on: https://github.com/seek-oss/vanilla-extract/issues/4#issuecomment-810842869
config.module.rules.push({
test: /\.css$/i,
sideEffects: true,
use: dev
? getGlobalCssLoader(
{
assetPrefix: options.config.assetPrefix,
future: {
webpack5: true,
},
isClient: !isServer,
isServer,
isDevelopment: dev,
},
[],
[]
)
: [MiniCssExtractPlugin.loader, 'css-loader'],
});
config.plugins.push(
new VanillaExtractPlugin()
);
if (!dev) {
config.plugins.push(
new MiniCssExtractPlugin({
filename: 'static/css/[contenthash].css',
chunkFilename: 'static/css/[contenthash].css',
ignoreOrder: true,
})
);
}
config.resolve.extensions = ['.js', '.jsx', '.ts', '.tsx', '.css', '.css.ts'];
// ------------------------------
// - Fonts -
config.module.rules.push({
test: /\.(woff|woff2|eot|ttf)$/,
loader: 'file-loader',
options: {
outputPath: 'static/font/',
publicPath: '/_next/static/font/'
}
});
return config;
},
};