-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget-config.js
71 lines (53 loc) · 1.86 KB
/
get-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
import { resolve } from 'path'
import fs from 'fs'
export default function getConfig(raw) {
const path = resolve(raw)
const configFile = `${path}/panels.config.js`
const pkg = require(`${path}/package.json`)
const rollupConfig = require(`${__dirname}/rollup.config.js`)(path)
const version = pkg.version || 'dev'
const defaultOpts = {
// static assets path to put your images, files, etc.
assets: `${path}/public/`,
// the path to the bundleda pp
bundle: `${path}/bundle/${version}`,
// the app's entry point
entry: `${path}/${pkg.main}`,
// dependencies that panels already bundles for us and we can safely declare as externals
externals: [
'react',
'react-dom',
'prop-types',
'panels',
'panels/blocks',
'panels/normalise-uri',
'panels/snap',
// legacy
'panels-ui',
],
// the app's name that panels will call it after, generally its the domain where it runs
expose: pkg.name,
// the domain to run on, defaults to the package name
domain: pkg.name,
// web handler for specific requests in dev mode
handler: (req, res, next) => next(),
// host to run the dev server at
host: '0.0.0.0',
// expose your own requires for your own use too
requires: [], // pkg.dependencies ? Object.keys(pkg.dependencies) : [],
// path to rollup.config.js used to transform the code
rollupConfig,
// the root to run on in that domain
root: '/',
secure: false,
// list of path regexes to serve as regular files and not to try to render them as panels paths
serveAsIs: [],
// path to the temporary bundle used when watching
tmp: `${path}/panels.app.tmp.js`,
// the version we're working on
version: version,
}
return fs.existsSync(configFile)
? Object.assign(defaultOpts, require(configFile))
: defaultOpts
}