forked from uber/baseweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
99 lines (90 loc) · 2.61 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
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
/* eslint-disable flowtype/require-valid-file-annotation */
/* eslint-env node */
const {resolve} = require('path');
const withImages = require('next-images');
const withMDX = require('@zeit/next-mdx')({
extension: /\.mdx?$/,
});
// The following modules need to be transpiled for IE11.
// If IE11 breaks again in the future, enable production source maps to find
// which module is causing the issue.
const withTM = require('next-transpile-modules')([
'@octokit/rest',
'@octokit/endpoint',
'@octokit/request',
'@octokit/request-error',
'@babel/core',
'@babel/code-frame',
'@babel/parser',
'@babel/generator',
'@babel/traverse',
'@babel/types',
'@babel/template',
'@babel/highlight',
'@babel/helpers',
'@babel/helper-plugin-utils',
'@babel/helper-builder-react-jsx',
'@babel/helper-function-name',
'@babel/helper-split-export-declaration',
'@babel/plugin-transform-react-jsx',
'@babel/plugin-transform-react-jsx-source',
'@babel/plugin-transform-react-jsx-self',
'@babel/plugin-transform-react-display-name',
'@babel/plugin-syntax-jsx',
'@babel/preset-react',
'octokit-pagination-methods',
'deprecation',
'vnopts',
'react-view',
'ansi-styles',
'debug',
'chalk',
'is-fullwidth-code-point',
'jest-docblock',
'gensync',
'string-width',
'jsesc',
]);
module.exports = withTM(
withMDX(
withImages({
images: {
loader: 'imgix',
},
typescript: {
ignoreBuildErrors: true,
},
publicRuntimeConfig: {
loadYard: process.env.LOAD_YARD,
},
trailingSlash: true,
webpack: (config, {buildId, dev, isServer, defaultLoaders}) => {
config.resolve.alias.baseui = resolve(__dirname, '../dist');
config.resolve.alias.examples = resolve(__dirname, 'examples');
// references next polyfills example: https://github.com/zeit/next.js/tree/canary/examples/with-polyfills
const originalEntry = config.entry;
config['node'] = {fs: 'empty'};
config.entry = async () => {
const entries = await originalEntry();
if (
entries['main.js'] &&
!entries['main.js'].includes('./helpers/polyfills.js')
) {
entries['main.js'].unshift('./helpers/polyfills.js');
}
return entries;
};
if (dev) {
config.devtool = 'inline-source-map';
}
return config;
},
pageExtensions: ['js', 'jsx', 'mdx'],
}),
),
);