-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
114 lines (106 loc) · 4.13 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
104
105
106
107
108
109
110
111
112
113
114
const path = require('path')
const util = require('util')
const withCss = require('@zeit/next-css')
const withSass = require('@zeit/next-sass')
const BG_IMAGES_DIRNAME = 'bgimages'
const withTM = require('next-transpile-modules')([
'@patternfly/react-core',
'@patternfly/react-icons',
'@patternfly/react-styles',
'@patternfly/react-table',
'@patternfly/react-tokens',
], { debug: false })
module.exports = withSass(withCss(
withTM({
// Webpack config from https://github.com/patternfly/patternfly-react-seed/blob/master/webpack.common.js
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\.(svg|ttf|eot|woff|woff2)$/,
// only process modules with this loader
// if they live under a 'fonts' or 'pficon' directory
include: [
path.resolve(__dirname, 'node_modules/patternfly/dist/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/pficon'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/pficon')
],
use: {
loader: 'file-loader',
options: {
// Limit at 50k. larger files emitted into separate files
limit: 5000,
publicPath: '/_next/static/fonts/',
outputPath: 'static/fonts/',
name: '[name].[ext]',
esModule: false,
},
},
})
config.module.rules.push({
test: /\.svg$/,
include: (input) => input.indexOf('background-filter.svg') > 1,
use: [
{
loader: 'url-loader',
options: {
limit: 5000,
publicPath: '/_next/static/svgs/',
outputPath: 'static/svgs/',
name: '[name].[ext]',
},
},
],
})
config.module.rules.push({
test: /\.svg$/,
// only process SVG modules with this loader if they live under a 'bgimages' directory
// this is primarily useful when applying a CSS background using an SVG
include: (input) => input.indexOf(BG_IMAGES_DIRNAME) > -1,
use: {
loader: 'svg-url-loader',
options: {},
},
})
config.module.rules.push({
test: /\.svg$/,
// only process SVG modules with this loader when they don't live under a 'bgimages',
// 'fonts', or 'pficon' directory, those are handled with other loaders
include: (input) =>
input.indexOf(BG_IMAGES_DIRNAME) === -1 &&
input.indexOf('fonts') === -1 &&
input.indexOf('background-filter') === -1 &&
input.indexOf('pficon') === -1,
use: {
loader: 'raw-loader',
options: {},
},
})
config.module.rules.push({
test: /\.(jpg|jpeg|png|gif)$/i,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-styles/css/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images')
],
use: [
{
loader: 'url-loader',
options: {
limit: 5000,
publicPath: '/_next/static/images/',
outputPath: 'static/images/',
name: '[name].[ext]',
},
},
],
})
return config
},
})
))