forked from csstree/csstree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
36 lines (34 loc) · 1.07 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
const path = require('path');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const json = require('@rollup/plugin-json');
const { terser } = require('rollup-plugin-terser');
const { lexer } = require('./lib');
function replaceContent(map) {
return {
name: 'file-content-replacement',
load(id) {
const key = path.relative('', id);
if (map.hasOwnProperty(key)) {
return map[key](id);
}
}
};
}
module.exports = {
input: 'lib/index.js',
output: [
{ name: 'csstree', format: 'umd', file: 'dist/csstree.js' },
{ name: 'csstree', format: 'umd', file: 'dist/csstree.min.js' }
],
plugins: [
resolve({ browser: true }),
replaceContent({
'data/index.js': () => `module.exports = ${JSON.stringify(lexer.dump(), null, 4)};`,
'package.json': id => `{ "version": "${require(id).version}" }`
}),
commonjs(),
json(),
terser({ include: /\.min\./ })
]
};