-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
71 lines (63 loc) · 1.69 KB
/
Copy pathindex.js
File metadata and controls
71 lines (63 loc) · 1.69 KB
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
module.exports =
(pluginOptions = {}) =>
(inputConfig = {}) => {
const extension = pluginOptions.extension || /\.org$/
const userProvidedOrgOptions = pluginOptions.options
const loader = {
loader: require.resolve('./org-js-loader'),
options: {
providerImportSource: 'next-org-import-source-file',
...userProvidedOrgOptions,
},
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
...inputConfig,
webpack(config, options) {
config.resolve.alias['next-org-import-source-file'] = [
'private-next-root-dir/src/org-components',
'private-next-root-dir/org-components',
'@orgajs/react',
require.resolve('./org-components.js'),
]
config.module.rules.push({
test: extension,
use: [options.defaultLoaders.babel, loader],
})
if (typeof inputConfig.webpack === 'function') {
return inputConfig.webpack(config, options)
}
return config
},
}
if (process.env.TURBOPACK) {
const orgRule = {
loaders: [loader],
as: '*.tsx',
condition: {
path: extension,
},
}
// Keep a unique glob key to reduce accidental rule ordering collisions.
const wildcardGlob = '{*,next-org-rule}'
let wildcardRule = inputConfig.turbopack?.rules?.[wildcardGlob] ?? []
wildcardRule = [
...(Array.isArray(wildcardRule) ? wildcardRule : [wildcardRule]),
orgRule,
]
nextConfig.turbopack = {
...inputConfig?.turbopack,
rules: {
...inputConfig?.turbopack?.rules,
[wildcardGlob]: wildcardRule,
},
resolveAlias: {
...inputConfig?.turbopack?.resolveAlias,
'next-org-import-source-file': '@orgajs/next/org-import-source',
},
}
}
return nextConfig
}