forked from LiamMartens/sanity-plugin-intl-input
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (57 loc) · 2.04 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
const fs = require('fs');
const path = require('path');
const babel = require('rollup-plugin-babel');
const cleaner = require('rollup-plugin-cleaner');
const external = require('rollup-plugin-peer-deps-external');
const postcss = require('rollup-plugin-postcss');
const commonjs = require('@rollup/plugin-commonjs');
const resolve = require('@rollup/plugin-node-resolve');
const { ifProd } = require('./utils/env');
const srcPath = (...p) => path.resolve.apply(undefined, [__dirname, 'src', ...p].filter(Boolean));
const libPath = (...p) => path.resolve.apply(undefined, [__dirname, 'lib', ...p].filter(Boolean));
module.exports = (name) => {
const indexFile = fs.readdirSync(srcPath(name)).find(f => f.startsWith('index.'));
return {
input: srcPath(name, indexFile),
output: [{
dir: libPath(name),
format: 'cjs',
sourceMap: true
}],
plugins: [
external(),
postcss({
modules: {
camelCase: true,
generateScopedName: '[hash:base64]',
},
minimize: false,
extensions: ['.css', '.scss']
}),
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
babel({
exclude: '**/node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx'],
runtimeHelpers: true,
}),
commonjs(),
ifProd(cleaner({
targets: [
libPath(name)
],
}))
].filter(Boolean),
external: [
'part:@sanity/base/client',
'part:@sanity/base/document-badges',
'part:@sanity/base/schema',
'part:@sanity/base/datastore/document',
'part:@sanity/base/document-actions',
'@sanity/desk-tool/lib/pane/PaneItem',
'@sanity/desk-tool/structure-builder',
'@sanity/state-router/lib/components/IntentLink'
]
};
};