emoji-picker-element/rollup.config.js

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-05-17 05:36:21 +02:00
import cjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
2020-05-31 18:34:17 +02:00
import mainSvelte from 'rollup-plugin-svelte'
import hotSvelte from 'rollup-plugin-svelte-hot'
2020-05-18 04:08:00 +02:00
import autoPreprocess from 'svelte-preprocess'
2020-05-17 05:36:21 +02:00
import { versionsAndTestEmoji } from './bin/versionsAndTestEmoji'
2020-05-10 04:39:47 +02:00
2020-05-31 18:34:17 +02:00
const dev = process.env.NODE_ENV !== 'production'
const svelte = dev ? hotSvelte : mainSvelte
// Build Database.js and Picker.js as separate modules at build times so that they are properly tree-shakeable.
// Most of this has to happen because customElements.define() has side effects
2020-05-10 04:39:47 +02:00
const baseConfig = {
plugins: [
resolve(),
cjs(),
2020-05-12 06:25:07 +02:00
json(),
2020-05-17 05:36:21 +02:00
replace({
'process.env.VERSIONS_AND_TEST_EMOJI': JSON.stringify(versionsAndTestEmoji)
}),
replace({
2020-06-04 05:12:43 +02:00
'../../../database/Database.js': './database.js',
delimiters: ['', '']
}),
2020-05-10 05:21:32 +02:00
svelte({
2020-05-17 19:56:31 +02:00
css: true,
2020-05-12 06:25:07 +02:00
customElement: true,
2020-05-31 18:34:17 +02:00
dev,
2020-05-18 04:08:00 +02:00
preprocess: autoPreprocess()
2020-05-10 05:21:32 +02:00
})
],
external: [
'../../../database/Database.js'
2020-05-10 04:39:47 +02:00
]
}
2020-05-10 05:13:50 +02:00
const entryPoints = [
2020-05-10 04:39:47 +02:00
{
2020-06-04 05:12:43 +02:00
input: './src/picker/components/Picker/Picker.svelte',
output: './picker.js'
},
{
input: './src/database/Database.js',
2020-06-04 05:12:43 +02:00
output: './database.js'
2020-05-10 04:39:47 +02:00
}
]
2020-05-10 05:13:50 +02:00
2020-06-04 05:12:43 +02:00
export default entryPoints.map(({ input, output }) => ({
2020-05-10 05:13:50 +02:00
...baseConfig,
input,
output: {
2020-06-04 05:12:43 +02:00
format: 'es',
file: output,
2020-05-31 18:34:17 +02:00
sourcemap: dev
2020-05-10 05:13:50 +02:00
}
2020-06-04 05:12:43 +02:00
}))