-
Notifications
You must be signed in to change notification settings - Fork 512
/
next.config.js
41 lines (38 loc) · 1.22 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
const withPlugins = require('next-compose-plugins')
const mdx = require('@zeit/next-mdx')
module.exports = withPlugins([
mdx({extension: /\.mdx?$/})
], {
/*
* Note: Prefixing assets with the fully qualified deployment URL
* makes them available even when the site is served from a path alias, as in
* <https://primer.style/components>
*/
assetPrefix: process.env.NOW_URL,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
sassLoaderOptions: {
includePaths: ['node_modules']
},
webpack(config, {dev}) {
// load primer-components.css as raw string
config.module.rules.push({
test: /\.css$/,
use: 'raw-loader'
})
// we only care about disabling mangling in production
if (dev) {
return config
}
for (const plugin of config.plugins) {
// duck type: is this an UglifyJS plugin?
if (plugin.options && plugin.options.uglifyOptions) {
/* eslint-disable camelcase, no-console */
console.warn('*** disabling mangling in UglifyJS plugin ***')
plugin.options.uglifyOptions.compress = {keep_fnames: true}
plugin.options.uglifyOptions.mangle.keep_fnames = true
/* eslint-enable camelcase, no-console */
}
}
return config
}
})