-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
34 lines (27 loc) · 998 Bytes
/
rollup.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
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
const childProcess = require('child_process')
const environment = process.env.NODE_ENV || 'development'
const version = childProcess.execSync('git rev-parse HEAD').toString().trim()
const intro = `window.SDQ = { environment: '${environment}', version: '${version}' }`
export default [
getConfig('src/browser/background.js', 'dist/background.js'),
getConfig('src/browser/content.js', 'dist/content.js'),
getConfig('src/browser/newtab.js', 'dist/newtab.js'),
getConfig('src/browser/popup.js', 'dist/popup.js')
]
function getConfig (inputPath, outputPath) {
const plugins = [nodeResolve({ mainFields: ['jsnext', 'main'] }), commonjs()]
const name = 'x'
const format = 'iife'
const sourcemap = true
const watch = {
include: ['src/**/*.js']
}
return {
plugins,
watch,
input: inputPath,
output: { name, format, sourcemap, intro, file: outputPath }
}
}