-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.js
91 lines (84 loc) · 2.45 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import alias from '@rollup/plugin-alias';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import { createRequire } from 'module';
import multiInput from 'rollup-plugin-multi-input';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { paramCase } from 'change-case';
import path from 'path';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import typescript from '@rollup/plugin-typescript';
const require = createRequire(import.meta.url);
const tailwindConfig = require('./tailwind.config.cjs');
const tailwindInJs = require('./.build/rollup-plugin-tailwind-in-js.cjs');
export default {
input: ['src/elements/public/*/index.ts'],
output: {
dir: 'dist/cdn',
format: 'esm',
chunkFileNames: 'shared-[hash].js',
},
plugins: [
multiInput({
relative: 'src/elements/public',
transformOutputPath: output => `foxy-${paramCase(path.dirname(output))}.js`,
}),
alias({
entries: [
{
find: /@foxy\.io\/sdk\/(.*)/,
replacement: '@foxy.io/sdk/dist/esm/$1',
},
],
}),
nodeResolve({ browser: true }),
tailwindInJs({ config: tailwindConfig, extensions: ['.ts'] }),
typescript({ outDir: 'dist/cdn' }),
commonjs(),
babel({
babelHelpers: 'bundled',
extensions: ['.ts'],
plugins: [
[
'template-html-minifier',
{
modules: {
'lit-html': ['html'],
'lit-element': ['html', { name: 'css', encapsulation: 'style' }],
},
strictCSS: true,
failOnError: false,
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
],
presets: [
[
'@babel/preset-env',
{
spec: true,
bugfixes: true,
modules: false,
targets: {
esmodules: true,
},
},
],
],
}),
replace({
'process.env.NODE_ENV': '"production"',
'process.env.FOXY_CDN': '"https://static.www.foxycart.com/beta/foxy-elements/0.3.0"',
}),
terser(),
copy({ targets: [{ src: 'src/static/translations/*', dest: 'dist/cdn/translations' }] }),
],
};