emoji-picker-element/rollup.config.js

79 lines
2.0 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 replace from '@rollup/plugin-replace'
import strip from '@rollup/plugin-strip'
2020-06-09 16:09:23 +02:00
import analyze from 'rollup-plugin-analyzer'
import { minifyHtmlLiteralsRollupPlugin } from './config/minifyHtmlLiteralsRollupPlugin.js'
import { buildStylesRollupPlugin } from './config/buildStylesRollupPlugin.js'
2020-05-10 04:39:47 +02:00
const { NODE_ENV, DEBUG, PERF } = process.env
const dev = NODE_ENV !== 'production'
2020-05-31 18:34:17 +02:00
// Build Database.test.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-17 05:36:21 +02:00
replace({
'import.meta.env.MODE': dev ? '"development"' : '"production"',
'import.meta.env.PERF': !!PERF,
2021-05-30 20:05:14 +02:00
preventAssignment: true
2020-05-17 05:36:21 +02:00
}),
replace({
2020-06-07 22:08:28 +02:00
'\'../database/Database.js\'': '\'./database.js\'',
2021-05-30 20:05:14 +02:00
delimiters: ['', ''],
preventAssignment: true
}),
minifyHtmlLiteralsRollupPlugin(),
buildStylesRollupPlugin(),
strip({
include: ['**/*.js'],
functions: [
(!dev && !PERF) && 'performance.*',
!dev && 'console.log'
].filter(Boolean)
}),
DEBUG && analyze({ summaryOnly: true })
],
external: [
2020-06-07 22:08:28 +02:00
'./database.js',
'../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
{
input: './src/picker/PickerElement.js',
output: './picker.js'
},
{
2020-06-07 05:46:03 +02:00
input: './src/database/Database.js',
2020-06-04 05:12:43 +02:00
output: './database.js'
2020-06-20 23:06:19 +02:00
},
{
input: './src/trimEmojiData.js',
output: './trimEmojiData.js'
},
{
input: './src/trimEmojiData.js',
output: './trimEmojiData.cjs',
format: 'cjs'
2020-05-10 04:39:47 +02:00
}
]
2020-05-10 05:13:50 +02:00
export default entryPoints.map(({ input, output, format = 'es', external = [], onwarn }) => {
2023-11-11 17:12:20 +01:00
return {
2020-06-21 20:55:27 +02:00
input,
output: {
format,
file: output,
sourcemap: dev,
exports: 'auto'
2023-11-11 17:12:20 +01:00
},
external: [...baseConfig.external, ...external],
plugins: baseConfig.plugins,
2023-11-11 17:12:20 +01:00
onwarn
2020-05-10 05:13:50 +02:00
}
2020-06-21 20:55:27 +02:00
})