-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
100 lines (95 loc) · 2.04 KB
/
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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* eslint-disable import/no-named-as-default */
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import jst from 'rollup-plugin-jst'
import pkg from './package.json'
import postcss from 'rollup-plugin-postcss'
import resolve from '@rollup/plugin-node-resolve'
import svgo from 'rollup-plugin-svgo'
import define from 'rollup-plugin-define'
import { terser } from 'rollup-plugin-terser'
import rollupYAML from '@rollup/plugin-yaml'
import yaml from 'js-yaml'
import { readFileSync } from 'fs'
const {
NODE_ENV = 'development',
I18N_SERVICE_URL = 'https://translate.sf.gov'
} = process.env
const prod = NODE_ENV === 'production'
const name = 'FormioSFDS'
const external = []
const commonPlugins = [
resolve(),
commonjs(),
json(),
jst({
extensions: ['.ejs'],
templateOptions: {
evaluate: /\{%([\s\S]+?)%\}/g,
interpolate: /\{\{([\s\S]+?)\}\}/g,
escape: /\{\{\{([\s\S]+?)\}\}\}/g,
variable: 'ctx'
}
}),
define({
replacements: {
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'process.env.I18N_SERVICE_URL': JSON.stringify(I18N_SERVICE_URL)
}
}),
svgo(
yaml.safeLoad(
readFileSync('svgo.config.yml', 'utf8')
)
),
babel({
babelHelpers: 'runtime'
}),
prod ? terser() : null
].filter(Boolean)
export default [
{
input: 'src/standalone.js',
external,
plugins: [
...commonPlugins,
postcss({
extensions: ['.css'],
inject: true
})
],
output: {
format: 'umd',
name,
file: pkg.browser,
sourcemap: prod
}
},
{
input: 'src/examples.js',
external,
plugins: [
...commonPlugins,
rollupYAML()
],
output: {
format: 'umd',
file: 'dist/examples.js',
sourcemap: true
}
},
{
input: 'src/portal.js',
external,
plugins: [
...commonPlugins,
rollupYAML()
],
output: {
format: 'umd',
file: 'dist/portal.js',
sourcemap: true
}
}
]