/
rollup.config.js
63 lines (58 loc) · 1.88 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
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import buble from 'rollup-plugin-buble';
import uglify from 'rollup-plugin-uglify';
import sass from 'node-sass';
const pkg = require('./package.json');
export default [
{
input: 'main.js',
output: {
file: pkg.main,
format: 'cjs',
name: 'cartcomponents',
sourcemap: true,
},
external: ['svelte/store.js'],
plugins: plugins()
}
];
function plugins() {
return [
svelte({
hydratable: true,
store: true,
cascade: false, // remove unused css
onwarn: function (warning, defaultHandler) {
if (warning.message === "Unused CSS selector") {
// suppress
} else {
defaultHandler(warning);
}
},
preprocess: {
style: ({ content, attributes }) => {
if (attributes.type !== 'text/scss') return;
return new Promise((fulfil, reject) => {
sass.render({
data: content,
includePaths: ['../comet/src'],
sourceMap: true,
outFile: 'x' // this is necessary, but is ignored
}, (err, result) => {
if (err) return reject(err);
fulfil({
code: result.css.toString(),
map: result.map.toString()
});
});
});
}
}
}),
buble(),
//uglify()
]
}