1 | import { resolve } from 'path'
|
2 | import fs from 'fs'
|
3 |
|
4 | export default function getConfig(raw) {
|
5 | const path = resolve(raw)
|
6 |
|
7 | const configFile = `${path}/panels.config.js`
|
8 | const pkg = require(`${path}/package.json`)
|
9 | const rollupConfig = require(`${__dirname}/rollup.config.js`)(path)
|
10 | const version = pkg.version || 'dev'
|
11 |
|
12 | const defaultOpts = {
|
13 | // static assets path to put your images, files, etc.
|
14 | assets: `${path}/public/`,
|
15 |
|
16 | // the path to the bundleda pp
|
17 | bundle: `${path}/bundle/${version}`,
|
18 |
|
19 | // the app's entry point
|
20 | entry: `${path}/${pkg.main}`,
|
21 |
|
22 | // dependencies that panels already bundles for us and we can safely declare as externals
|
23 | externals: Object.keys(
|
24 | require('panels/package.json').dependencies
|
25 | ).concat([
|
26 | 'redux-promise',
|
27 | 'panels'
|
28 | ]),
|
29 |
|
30 | // the app's name that panels will call it after, generally its the domain where it runs
|
31 | expose: pkg.name,
|
32 |
|
33 | // the domain to run on, defaults to the package name
|
34 | domain: pkg.name,
|
35 |
|
36 | // web handler for specific requests in dev mode
|
37 | handler: (req, res, next) => next(),
|
38 |
|
39 | // host to run the dev server at
|
40 | host: '0.0.0.0',
|
41 |
|
42 | // expose your own requires for your own use too
|
43 | requires: [], // pkg.dependencies ? Object.keys(pkg.dependencies) : [],
|
44 |
|
45 | // path to rollup.config.js used to transform the code
|
46 | rollupConfig,
|
47 |
|
48 | // the root to run on in that domain
|
49 | root: '/',
|
50 |
|
51 | secure: false,
|
52 |
|
53 | // list of path regexes to serve as regular files and not to try to render them as panels paths
|
54 | serveAsIs: [],
|
55 |
|
56 | // path to the temporary bundle used when watching
|
57 | tmp: `${path}/panels.app.tmp.js`,
|
58 |
|
59 | // the version we're working on
|
60 | version: version
|
61 | }
|
62 |
|
63 |
|
64 | return fs.existsSync(configFile) ?
|
65 | Object.assign(defaultOpts, require(configFile)) :
|
66 | defaultOpts
|
67 | }
|