-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (35 loc) · 1.08 KB
/
index.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
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';
import fs from 'fs';
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
class GraphJsonResolverLoader extends ResourceInterface {
constructor(compilation) {
super(compilation);
}
shouldResolve(url) {
return url.pathname === '/graph.json' && process.env.__GWD_COMMAND__ === 'develop';
}
resolve() {
return new Request(new URL('./graph.json', this.compilation.context.scratchDir));
}
}
const greenwoodThemeStarterPresentation = (options = {}) => [{
type: 'context',
name: `${packageJson.name}:context`,
provider: (compilation) => {
const layoutsLocation = options.__isDevelopment
? new URL('./templates/', compilation.context.userWorkspace)
: new URL('./dist/templates/', import.meta.url);
return {
layouts: [
layoutsLocation
]
};
}
}, {
type: 'resource',
name: `${packageJson.name}:resource`,
provider: (compilation) => new GraphJsonResolverLoader(compilation)
}];
export {
greenwoodThemeStarterPresentation
};