-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
82 lines (74 loc) · 2.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
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
/*eslint-disable */
const path = require('path')
const glob = require('glob')
const cfg = require('./config')
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
webpack: (config, { dev }) => {
config.module.rules.push(
{
test: /\.(css|scss)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]'
}
},
{
test: /\.css$/,
use: ['babel-loader', 'raw-loader',
{
loader: 'css-loader',
options: {
minimize: true,
importLoaders: 1,
localIdentName: '[local]-[hash:base64:5]'
}
}, 'postcss-loader']
},
{
test: /\.s(a|c)ss$/,
use: ['babel-loader', 'raw-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
context: '/', // <- putting this line right under "options" did the trick
sassLoader: {
includePaths: [
path.resolve(__dirname, 'vendor/zurb/foundation/scss'),
]
},
includePaths: ['styles', 'node_modules']
.map(d => path.join(__dirname, d))
.map(g => glob.sync(g))
.reduce((a, c) => a.concat(c), [])
}
}
]
}
)
// Perform customizations to config
config.module.rules = config.module.rules.map(rule => {
if(rule.loader === 'babel-loader') {
rule.options.cacheDirectory = false
}
return rule
})
if (config.resolve.alias) {
delete config.resolve.alias['react']
delete config.resolve.alias['react-dom']
}
// add an asset prefix for exporting the assets
if (isProd) {
config.output.publicPath = `${cfg.appConfig.assetPrefix}${config.output.publicPath}`; // affects 'chunks'
}
return config
},
assetPrefix: isProd ? cfg.appConfig.assetPrefix : '', // affects page bundles and app/commons/vendor scripts
exportPathMap: function () {
return {
"/": { page: "/" },
// "/other": { page: "/other" },
}
},
}