forked from reworkcss/css
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
89 lines (86 loc) · 2.07 KB
/
Copy pathrollup.config.mjs
File metadata and controls
89 lines (86 loc) · 2.07 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
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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
// Fix source map paths: tsconfig rootDir:"." causes extra "../" level
// ../../../src/ → ../../src/ so paths resolve correctly within the package
const fixSourceMapPath = (relativeSourcePath) =>
relativeSourcePath.replace(/^(\.\.\/)*src\//, '../../src/');
const config = [
{
input: 'src/index.ts',
output: {
name: 'cssTools',
file: 'dist/umd/adobe-css-tools.js',
format: 'umd',
sourcemap: true,
exports: 'named',
sourcemapPathTransform: fixSourceMapPath,
},
plugins: [
resolve(),
commonjs(),
typescript({
outputToFilesystem: false,
compilerOptions: {
sourceMap: true,
},
}),
terser(),
],
},
{
input: 'src/index.ts',
output: [
{
name: 'cssTools',
format: 'cjs',
file: 'dist/cjs/adobe-css-tools.cjs',
dynamicImportInCjs: false,
sourcemap: true,
exports: 'named',
sourcemapPathTransform: fixSourceMapPath,
},
],
plugins: [
commonjs({
transformMixedEsModules: true,
}),
typescript(),
terser(),
],
},
{
input: 'src/index.ts',
output: [
{
name: 'cssTools',
format: 'esm',
file: 'dist/esm/adobe-css-tools.mjs',
sourcemap: true,
exports: 'named',
sourcemapPathTransform: fixSourceMapPath,
},
],
plugins: [
typescript({
outputToFilesystem: false,
compilerOptions: {
sourceMap: true,
},
}),
terser(),
],
},
{
input: 'src/index.ts',
output: [
{ file: 'dist/esm/adobe-css-tools.d.mts', format: 'es' },
{ file: 'dist/cjs/adobe-css-tools.d.cts', format: 'es' },
{ file: 'dist/umd/adobe-css-tools.d.ts', format: 'es' },
],
plugins: [dts()],
},
];
export default config;