-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
47 lines (45 loc) · 1.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
import { readFileSync } from 'fs'
import postcss from 'rollup-plugin-postcss'
import postcssImport from 'postcss-import'
import postcssNested from 'postcss-nested'
import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
/**
* Create a base rollup config
* @param {Record<string,any>} pkg Imported package.json
* @param {string[]} external Imported package.json
* @returns {import('rollup').RollupOptions}
*/
export function createConfig({ input = 'index.ts', pkg, external = [] }) {
return [
{
input,
onwarn: (warning) => {
throw Object.assign(new Error(), warning)
},
strictDeprecations: true,
output: {
// change this output file to development
// e.g. file: '/Users/xxx/.markflowy/themes/markflowy-theme-template/index.js',
file: pkg.browser,
format: 'es',
sourcemap: true,
entryFileNames: '[name].js',
},
plugins: [
resolve(),
postcss({
plugins: [postcssImport(), postcssNested()],
extract: false,
sourceMap: false,
minimize: true,
}),
typescript({ sourceMap: true }),
],
},
]
}
export default createConfig({
input: 'src/index.ts',
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')),
})