-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrollup.config.js
47 lines (43 loc) · 1.15 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
import fs from 'fs';
import replace from 'rollup-plugin-replace';
import vue from 'rollup-plugin-vue';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
let banner = `
/** MIT licence */
/** https://github.com/bookingcom/powercalculator */
`;
export default {
banner,
input: 'src/index.js',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify( 'development' )
}),
resolve(),
commonjs({
include: ['node_modules/**'],
}),
vue({
css (style, styles, compiler) {
fs.writeFileSync('dist/powercalculator.css', styles.reduce((str, styleData) => {
let { id, $compiled } = styleData,
{ code } = $compiled,
relativeVuePath = id.replace(__dirname + '/src/', ''),
codeTrimLineBreaks = code.replace(/[\n]+/g, '\n');
str += `\n/* ${relativeVuePath} */\n${codeTrimLineBreaks}\n`;
return str
}, ''));
}
})
],
output: {
banner: banner,
name: 'powercalculator',
file: 'dist/powercalculator.js',
format: 'umd',
amd: {
id: 'powercalculator'
}
}
}