-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
46 lines (40 loc) · 1.14 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
const webpack = require('webpack')
const path = require('path')
const fs = require('fs')
const withLess = require('@zeit/next-less')
const withSass = require('@zeit/next-sass')
const withCSS = require('@zeit/next-css')
const withImages = require('next-images')
const lessToJS = require('less-vars-to-js')
// Where your antd-custom.less file lives
const themeVariables = lessToJS(
fs.readFileSync(
path.resolve(__dirname, './src/styles/antd-custom.less'),
'utf8'
)
)
// fix: prevents error when .less files are required by node
if (typeof require !== 'undefined') {
require.extensions['.less'] = file => {}
}
//breaking up
const webpackWithSass = withSass({
distDir: 'build',
webpack: (config, { isServer }) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
'~': path.resolve(__dirname, './src')
}
return config
}
})
const webpackWithLess = withLess({
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: themeVariables // make your antd custom effective
}
})
const webpackConfigObj = withImages(
withCSS({ ...webpackWithLess, ...webpackWithSass })
)
module.exports = webpackConfigObj