forked from bustle/mobiledoc-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
74 lines (72 loc) · 1.78 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
import path from 'path'
import globImport from 'rollup-plugin-glob-import'
import alias from '@rollup/plugin-alias'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import serve from 'rollup-plugin-serve'
import copy from 'rollup-plugin-copy'
import typescript from '@rollup/plugin-typescript'
function commonPlugins() {
return [
resolve({ extensions: ['.js', '.ts'] }),
commonjs(),
alias({
entries: [
{
find: 'mobiledoc-kit',
replacement: path.join(__dirname, 'src/js'),
},
],
}),
typescript({ noEmitOnError: false }),
]
}
export default args => [
{
input: 'src/js/index.ts',
plugins: commonPlugins(),
output: {
file: 'dist/mobiledoc.js',
format: 'es',
sourcemap: true
}
},
{
input: 'src/js/index.ts',
plugins: commonPlugins(),
output: {
file: 'dist/mobiledoc.cjs',
format: 'cjs',
sourcemap: true
}
},
{
input: 'tests/index.ts',
plugins: [
...commonPlugins(),
globImport({
// without this option, the plugin will try to parse imported files (as
// JS) and fail with TS files
format: 'import'
}),
copy({
targets: [
{ src: 'dist/mobiledoc.js', dest: 'assets/demo' },
{ src: 'src/css/mobiledoc-kit.css', dest: 'dist', rename: 'mobiledoc.css' },
{ src: 'src/css/mobiledoc-kit.css', dest: 'assets/demo/', rename: 'mobiledoc.css' },
],
}),
args.watch &&
serve({
contentBase: '',
// eslint-disable-next-line no-process-env
port: process.env.PORT || 4200,
}),
],
output: {
file: 'dist/tests.js',
format: 'es',
sourcemap: true,
},
},
]