forked from CannerCMS/canner-firebase-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
77 lines (70 loc) · 2.39 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
const pkg = require("./package.json");
const withLess = require('@zeit/next-less');
const withCss = require('@zeit/next-css');
const path = require("path");
const theme = pkg.theme;
// fix: prevents error when .less files are required by node
if (typeof require !== 'undefined') {
require.extensions['.less'] = (file) => {}
require.extensions['.css'] = (file) => {}
}
// antd + nextjs
// https://github.com/zeit/next.js/tree/canary/examples/with-ant-design
module.exports = withCss(withLess({
lessLoaderOptions: {
modifyVars: theme,
javascriptEnabled: true
},
webpack: (config, {}) => {
const internalNodeModulesRegExp = /@zeit(?!.*node_modules)|\.schema\.js$|canner\.def\.js$|\.less$/
// overwrite external paths
// https://github.com/zeit/next.js/pull/3732/files#diff-0b0406776536850213e57e76340d2a2dR10
config.externals = config.externals.map(external => {
if (typeof external !== "function") return external
return (ctx, req, cb) => (internalNodeModulesRegExp.test(req) ? cb() : external(ctx, req, cb))
})
config.resolve.extensions = [".wasm", ".mjs", ".js", ".json", ".less"]
config.resolve.alias["styled-components"] = path.resolve(__dirname, 'node_modules', 'styled-components');
// with antd example using next.js
// https://github.com/zeit/next.js/tree/canary/examples/with-ant-design
config.module.rules.push(
// loader for canner.schema.js
{
test: /\.schema\.js|canner\.def\.js$/,
// include by files and folders who match the pattern.
include: [
path.join(__dirname, 'schema'),
path.join(__dirname, 'node_modules')
],
use: [
{loader: 'canner-schema-loader'},
{
loader: 'babel-loader',
options: {
presets: [
["next/babel", {
"preset-env": {modules: 'commonjs'},
"transform-runtime": {
helpers: true,
regenerator: true
}
}]
],
plugins: [
"transform-flow-strip-types"
]
}
}
]
}
);
return config;
},
// exportPathMap: function(defaultPathMap) {
// return {
// '/': { page: '/' },
// '/login': { page: '/login' },
// '/dashboard': { page: '/dashboard' }
// }
// }
}))