-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
112 lines (103 loc) · 2.44 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
// Rollup plugins
import babel from 'rollup-plugin-babel';
import { uglify } from 'rollup-plugin-uglify';
import postcss from 'rollup-plugin-postcss';
import commonjs from 'rollup-plugin-commonjs';
import vue from 'rollup-plugin-vue';
import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
// Postcss plugins
import precss from 'precss';
import postcssUtilities from 'postcss-utilities';
import postcssPresetEnv from 'postcss-preset-env';
import cssnano from 'cssnano';
let plugins = [
resolve({
only: ['vue-property-decorator', 'vue-class-component']
}),
commonjs(),
typescript(),
vue({
defaultLang: { script: 'ts' }
}),
postcss({
extensions: ['.css'],
plugins: [
precss(),
postcssPresetEnv({ stage: 0 }),
cssnano(),
postcssUtilities()
],
}),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.vue']
})
];
// let outputs = [
// {
// file: 'dist/vue-d2b.cjs.js',
// sourceMap: 'inline',
// format: 'cjs',
// name: 'vued2b'
// },
// {
// file: 'dist/vue-d2b.js',
// format: 'iife',
// globals: {'d2b': 'd2b', 'd3-selection': 'd3', 'd3-transition': 'd3', 'vue': 'Vue'},
// sourceMap: 'inline',
// name: 'vued2b'
// },
// ];
var outputs;
if (process.env.BUILD === 'cjs') {
outputs = [
{
file: 'dist/vue-d2b.cjs.js',
sourceMap: 'inline',
format: 'cjs',
name: 'vued2b'
},
];
}
if (process.env.BUILD === 'js') {
outputs = [
{
file: 'dist/vue-d2b.js',
format: 'iife',
globals: {'d2b': 'd2b', 'd3-selection': 'd3', 'd3-transition': 'd3', 'vue': 'Vue'},
sourceMap: 'inline',
name: 'vued2b'
},
];
plugins.push(
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VUE_ENV': JSON.stringify('browser')
})
);
}
if (process.env.BUILD === 'min') {
outputs = [
{
file: 'dist/vue-d2b.min.js',
format: 'iife',
globals: {'d2b': 'd2b', 'd3-selection': 'd3', 'd3-transition': 'd3', 'vue': 'Vue'},
sourceMap: 'inline',
name: 'vued2b'
}
];
plugins.push(
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VUE_ENV': JSON.stringify('browser')
})
);
plugins.push(uglify());
}
export default {
input: 'src/index.ts',
output: outputs,
plugins: plugins,
};