-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
119 lines (114 loc) · 3.06 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import babel from 'rollup-plugin-babel';
import sourcemaps from 'rollup-plugin-sourcemaps';
import {terser} from "rollup-plugin-terser";
import postcss from 'rollup-plugin-postcss'
import atImport from 'postcss-import';
/**
* Both Babel and Rollup have features to combine the source maps of two consecutive transformations. It is therefore
* important not to use both. Luckily, we can set Babel’s `inputSourceMap` option to false, in order to make Babel
* ignore the source maps in src/target/js that were created by the TypeScript compiler.
*/
const inputSourceMap = false;
function defaults() {
return {
external: [
'@fschopp/project-planning-for-you-track',
's-array',
's-js',
'sortablejs',
'surplus'
],
input: 'target/main/index.js',
// Oddly, rollup 1.14.6 removes all class definitions if tree shaking is turned on.
treeshake: false,
};
}
function outputDefaults() {
return {
sourcemap: true,
sourcemapExcludeSources: true,
globals: {
'@fschopp/project-planning-for-you-track': 'ProjectPlanningForYouTrack',
's-array': 'SArray',
's-js': 'S',
'sortablejs': 'Sortable',
'surplus': 'Surplus'
},
};
}
export default [
{
...defaults(),
input: 'src/css/index.js',
output: {
...outputDefaults(),
file: 'dist/index.js',
format: 'umd',
name: 'ProjectPlanningUiForYouTrack',
},
plugins: [
sourcemaps(),
// Unfortunately, rollup 1.11.3 does not pick up the .babelrc.js file.
babel({
inputSourceMap,
presets: ['@babel/preset-env'],
plugins: ['babel-plugin-unassert']
}),
postcss({
extract: true,
plugins: [
atImport(),
],
// While we could set property 'sourceMap' to true in order to generate a source map, it unfortunately does not
// have the correct relative path. The issue seems with rollup-plugin-postcss; it sets both the 'from' and 'to'
// options to the same value. See:
// https://github.com/egoist/rollup-plugin-postcss/blob/v2.0.3/src/postcss-loader.js#L104-L115
// https://github.com/postcss/postcss-import
// sourceMap: true,
}),
]
},
{
...defaults(),
input: 'src/css/index.js',
output: {
...outputDefaults(),
file: 'dist/index.min.js',
format: 'umd',
name: 'ProjectPlanningUiForYouTrack',
},
plugins: [
sourcemaps(),
// Unfortunately, rollup 1.11.3 does not pick up the .babelrc.js file.
babel({
inputSourceMap,
presets: ['@babel/preset-env'],
plugins: ['babel-plugin-unassert']
}),
terser(),
postcss({
extract: true,
plugins: [
atImport(),
],
minimize: true,
}),
]
},
{
...defaults(),
output: {
...outputDefaults(),
dir: 'dist/es6/',
format: 'esm',
},
plugins: [
sourcemaps(),
babel({
inputSourceMap,
plugins: ['babel-plugin-unassert']
}),
],
preserveModules: true,
},
];