1 | const path = require('path')
|
2 | const node = require('@rola/preset-node')
|
3 |
|
4 | const cwd = process.cwd()
|
5 |
|
6 | module.exports = function createConfig ({ entry, watch, env, alias, banner, presets }) {
|
7 | const isNode = /server/.test(entry)
|
8 |
|
9 | return {
|
10 | in: entry,
|
11 | out: isNode ? {
|
12 | path: path.join(cwd, 'build'),
|
13 | libraryTarget: 'commonjs2'
|
14 | } : path.join(cwd, 'build/assets'),
|
15 | env: env || {},
|
16 | alias: alias || {},
|
17 | presets: [].concat(presets || []).concat([
|
18 | isNode && node()
|
19 | ].filter(Boolean)),
|
20 | banner: isNode ? (
|
21 | `require('source-map-support').install();`
|
22 | ) : (
|
23 | '/** built with rola */'
|
24 | ) + banner || ''
|
25 | }
|
26 | }
|