generated from gfazioli/mantine-flip
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
53 lines (50 loc) · 1.49 KB
/
rollup.config.mjs
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
import path from 'node:path';
import nodeExternals from 'rollup-plugin-node-externals';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import esbuild from 'rollup-plugin-esbuild';
import postcss from 'rollup-plugin-postcss';
import banner from 'rollup-plugin-banner2';
import { createGenerateScopedName } from 'hash-css-selector';
const outputDir = path.join(process.cwd(), './package/dist');
export default {
input: path.join(process.cwd(), './package/src/index.ts'),
output: [
{
format: 'es',
entryFileNames: '[name].mjs',
dir: path.join(outputDir, 'esm'),
preserveModules: true,
sourcemap: true,
},
{
format: 'cjs',
entryFileNames: '[name].cjs',
dir: path.join(outputDir, 'cjs'),
preserveModules: true,
sourcemap: true,
},
],
plugins: [
nodeExternals({
packagePath: path.join(process.cwd(), 'package/package.json'),
}),
nodeResolve({ extensions: ['.ts', '.tsx', '.js', '.jsx'] }),
esbuild({
sourceMap: false,
tsconfig: path.resolve(process.cwd(), 'tsconfig.build.json'),
}),
replace({ preventAssignment: true }),
postcss({
extract: true,
modules: { generateScopedName: createGenerateScopedName('me') },
minimize: true,
}),
banner((chunk) => {
if (chunk.fileName !== 'index.js' && chunk.fileName !== 'index.mjs') {
return "'use client';\n";
}
return undefined;
}),
],
};