-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
83 lines (80 loc) · 2.33 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
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
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import alias from '@rollup/plugin-alias';
import { visualizer } from "rollup-plugin-visualizer";
import path from 'path';
import { fileURLToPath } from 'url';
import markdownContentPlugin from './plugins/markdown_plugin.js';
import pkg from "./package.json" assert { type: 'json' };
import json from '@rollup/plugin-json';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import postcss from 'rollup-plugin-postcss';
export default {
input: 'src/index.js', // Main JavaScript file
external: ['preact', 'preact/hooks', 'prop-types'], // Don’t bundle Preact
plugins: [
alias({
entries: [
{ find: '@hanafi', replacement: path.resolve(__dirname, 'contents/hanafi/') },
{ find: '@components', replacement: path.resolve(__dirname, 'src/components/') },
{ find: '@hooks', replacement: path.resolve(__dirname, 'src/hooks/') },
{ find: '@utils', replacement: path.resolve(__dirname, 'src/utils/') },
{ find: '@src', replacement: path.resolve(__dirname, 'src/') },
]
}),
markdownContentPlugin(),
json(),
postcss({
extensions: ['.css'],
modules: true
}),
resolve(), // Locate and bundle dependencies in 'node_modules'
babel({
exclude: 'node_modules/**', // Only transpile our source code
extensions: ['.js', '.jsx'],
babelHelpers: 'bundled'
}),
commonjs(), // Convert CommonJS modules to ES6
visualizer(),
],
output: [
{
file: pkg.main,
format: 'cjs',
name: '@al-mabsut/muslimah',
sourcemap: true,
globals: {
preact: 'Preact'
}
},
{
file: pkg.module,
format: 'esm',
name: '@al-mabsut/muslimah',
sourcemap: true,
globals: {
preact: 'Preact'
}
},
{
file: 'node_modules/@al-mabsut/muslimah/dist/cjs/bundle.js',
format: 'cjs',
name: '@al-mabsut/muslimah',
sourcemap: true,
globals: {
preact: 'Preact'
}
},
{
file: 'node_modules/@al-mabsut/muslimah/dist/esm/bundle.js',
format: 'esm',
name: '@al-mabsut/muslimah',
sourcemap: true,
globals: {
preact: 'Preact'
}
}
]
};