forked from opencollective/opencollective-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
103 lines (95 loc) · 2.67 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
require('./env');
const withCSS = require('@zeit/next-css');
const withSourceMaps = require('@zeit/next-source-maps');
const nextConfig = {
webpack: (config, { webpack }) => {
config.plugins.push(
// Ignore __tests__
new webpack.IgnorePlugin(/[\\/]__tests__[\\/]/),
// Only include our supported locales
new webpack.ContextReplacementPlugin(/moment[\\/]locale$/, /en|fr|es|ja/),
// Set extra environment variables accessible through process.env.*
// Will be replaced by webpack by their values!
new webpack.EnvironmentPlugin({
API_KEY: null,
API_URL: null,
INVOICES_URL: null,
GIFTCARDS_GENERATOR_URL: null,
DYNAMIC_IMPORT: true,
WEBSITE_URL: null,
NCP_BETA_COLLECTIVES: null,
NCP_IS_DEFAULT: null,
}),
);
if (process.env.WEBPACK_BUNDLE_ANALYZER) {
// eslint-disable-next-line node/no-unpublished-require
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
generateStatsFile: true,
openAnalyzer: false,
}),
);
}
config.module.rules.push({
test: /\.md$/,
use: ['babel-loader', 'raw-loader', 'markdown-loader'],
});
// Inspired by https://github.com/rohanray/next-fonts
// Load Bootstrap and Font-Awesome fonts
config.module.rules.push({
test: /fonts[\\/].*\.(woff|woff2|eot|ttf|otf|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
fallback: 'file-loader',
publicPath: '/_next/static/fonts/',
outputPath: 'static/fonts/',
name: '[name]-[hash].[ext]',
},
},
],
});
// Configuration for static/marketing pages
config.module.rules.unshift(
{
test: /static[\\/].*\.(html)$/,
use: {
loader: 'html-loader',
},
},
{
test: /static[\\/].*\.(css)$/,
use: {
loader: 'raw-loader',
},
},
{
test: /static[\\/].*\.(jpg|gif|png|svg)$/,
use: {
loader: 'file-loader',
options: {
publicPath: '/_next/static/img/',
outputPath: 'static/img/',
name: '[name]-[hash].[ext]',
},
},
},
);
// Load SVGs in base64
config.module.rules.push({
test: /components\/.*\.(svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 1000000,
},
},
});
return config;
},
};
module.exports = withSourceMaps(withCSS(nextConfig));