-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
54 lines (48 loc) · 1.59 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
/**
* This config file is because nextjs does not natively support CSS and TypeScript, so we must
* use a loader to make sure the nextjs compiler knows to use CSS and TypeScript when we compile
* as well as next-images which allows for images to be imported correctly.
*
* Last modified:
* William Kwok
* June 5, 2019
*/
const withPlugins = require("next-compose-plugins");
const withTypescript = require("@zeit/next-typescript");
const withCSS = require("@zeit/next-css");
const withImages = require("next-images");
// This is from a package that could not be installed correctly.
const withPdf = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
const { isServer } = options;
nextConfig = Object.assign({ inlineImageLimit: 8192, assetPrefix: "" }, nextConfig);
if (!options.defaultLoaders) {
throw new Error(
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade'
)
}
config.module.rules.push({
test: /\.(pdf)$/,
exclude: nextConfig.exclude,
use: [
{
loader: "url-loader",
options: {
limit: nextConfig.inlineImageLimit,
fallback: "file-loader",
publicPath: `${nextConfig.assetPrefix}/_next/static/images/`,
outputPath: `${isServer ? "../" : ""}static/images/`,
name: "[name]-[hash].[ext]"
}
}
]
});
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}
module.exports = withPlugins([withTypescript, withCSS, withImages, withPdf]);