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'
|
2021-05-31 17:45:59 +02:00
|
|
|
import strip from '@rollup/plugin-strip'
|
2020-06-09 16:09:23 +02:00
|
|
|
import analyze from 'rollup-plugin-analyzer'
|
2023-06-18 21:14:18 +02:00
|
|
|
import { buildStyles } from './bin/buildStyles.js'
|
2023-12-17 21:28:46 +01:00
|
|
|
import { minifyHTMLLiterals } from 'minify-html-literals'
|
2020-05-10 04:39:47 +02:00
|
|
|
|
2021-07-02 18:58:05 +02:00
|
|
|
const { NODE_ENV, DEBUG } = process.env
|
2021-05-31 17:45:59 +02:00
|
|
|
const dev = NODE_ENV !== 'production'
|
2020-05-31 18:34:17 +02:00
|
|
|
|
2020-06-07 04:36:45 +02:00
|
|
|
// Build Database.test.js and Picker.js as separate modules at build times so that they are properly tree-shakeable.
|
2020-06-02 06:24:46 +02:00
|
|
|
// Most of this has to happen because customElements.define() has side effects
|
2020-05-10 04:39:47 +02:00
|
|
|
const baseConfig = {
|
|
|
|
plugins: [
|
|
|
|
resolve(),
|
2020-06-02 06:24:46 +02:00
|
|
|
cjs(),
|
2020-05-17 05:36:21 +02:00
|
|
|
replace({
|
2020-06-05 03:31:31 +02:00
|
|
|
'process.env.NODE_ENV': dev ? '"development"' : '"production"',
|
2021-05-30 20:05:14 +02:00
|
|
|
'process.env.PERF': !!process.env.PERF,
|
2021-08-14 03:09:40 +02:00
|
|
|
'process.env.STYLES': JSON.stringify(buildStyles()),
|
2021-05-30 20:05:14 +02:00
|
|
|
preventAssignment: true
|
2020-05-17 05:36:21 +02:00
|
|
|
}),
|
2020-06-02 06:24:46 +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
|
2020-06-02 06:24:46 +02:00
|
|
|
}),
|
2023-12-17 21:28:46 +01:00
|
|
|
{
|
|
|
|
name: 'minify-html-in-tag-template-literals',
|
|
|
|
transform (content, id) {
|
|
|
|
if (id.includes('PickerTemplate.js')) {
|
|
|
|
return minifyHTMLLiterals(content, {
|
|
|
|
fileName: id
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-05-31 17:45:59 +02:00
|
|
|
strip({
|
2023-12-17 21:28:46 +01:00
|
|
|
include: ['**/*.js'],
|
2021-05-31 17:45:59 +02:00
|
|
|
functions: [
|
|
|
|
(!dev && !process.env.PERF) && 'performance.*',
|
|
|
|
!dev && 'console.log'
|
|
|
|
].filter(Boolean)
|
|
|
|
}),
|
2021-07-02 18:58:05 +02:00
|
|
|
DEBUG && analyze({ summaryOnly: true })
|
2020-06-02 06:24:46 +02:00
|
|
|
],
|
|
|
|
external: [
|
2020-06-07 22:08:28 +02:00
|
|
|
'./database.js',
|
2020-06-07 10:10:43 +02:00
|
|
|
'../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-07 10:10:43 +02:00
|
|
|
input: './src/picker/PickerElement.js',
|
2023-12-17 21:28:46 +01:00
|
|
|
output: './picker.js'
|
2020-06-02 06:24:46 +02:00
|
|
|
},
|
|
|
|
{
|
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
|
|
|
|
2023-12-17 21:28:46 +01: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,
|
2020-08-17 05:57:11 +02:00
|
|
|
sourcemap: dev,
|
|
|
|
exports: 'auto'
|
2023-11-11 17:12:20 +01:00
|
|
|
},
|
|
|
|
external: [...baseConfig.external, ...external],
|
2023-12-17 21:28:46 +01:00
|
|
|
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
|
|
|
})
|