-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
36 lines (31 loc) · 947 Bytes
/
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
import { nodeResolve} from '@rollup/plugin-node-resolve';
import * as fs from 'fs';
import * as path from 'path';
function outDir(relPath) {
const nodeModulesPath = `./node_modules/${relPath}`
const parentDir = path.dirname(relPath)
// Just some basic logic how to generated output-paths under src/lib
if (`${path.basename(parentDir)}.js` === path.basename(relPath)) {
// lit-element/lit-element.js is simplified to 'src/lib/lit-element.js'
return path.dirname(parentDir)
}
else {
return path.dirname(relPath)
}
}
export default JSON.parse(fs.readFileSync('package.json', 'utf8')).rollup.webDependencies.map(relPath => {
console.log("Processing:", relPath)
const nodeModulesPath = `./node_modules/${relPath}`
return {
input: [
nodeModulesPath
],
output: {
dir: 'src/lib/' + outDir(relPath),
format: 'esm',
},
plugins: [nodeResolve({
browser: true
})]
};
});