-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
39 lines (37 loc) · 1.15 KB
/
Copy pathrollup.config.js
File metadata and controls
39 lines (37 loc) · 1.15 KB
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
import replace from '@rollup/plugin-replace';
import typescript from 'rollup-plugin-typescript2';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-serve';
import { readFileSync } from 'fs';
const dev = process.env.ROLLUP_WATCH;
const production = process.env.BUILD === 'production';
const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
export default {
input: 'src/parqet-card.ts',
output: {
file: 'custom_components/parqet/frontend/parqet-card.js',
format: 'es',
sourcemap: !production,
inlineDynamicImports: true,
},
plugins: [
replace({ preventAssignment: true, __VERSION__: pkg.version }),
nodeResolve({ browser: true }),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
clean: true,
}),
production && terser({ format: { comments: false } }),
dev &&
serve({
contentBase: ['custom_components/parqet/frontend', '.'],
port: 3000,
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
].filter(Boolean),
};