This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/rollup.config.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-12-04 14:07:14 +08:00
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import bundles from './build/index'
2019-12-18 15:28:32 +08:00
import fs from 'fs'
import path from 'path'
2019-12-04 14:07:14 +08:00
2019-12-18 15:28:32 +08:00
function readDirs(dirPath, files) {
if (fs.statSync(dirPath).isDirectory()) {
fs.readdirSync(dirPath).forEach(e => {
readDirs(path.join(dirPath, e), files)
})
} else {
for (let bundle of bundles) {
if (dirPath.match(new RegExp(`^${bundle}`))) {
files.push(dirPath)
}
2019-12-04 14:07:14 +08:00
}
}
2019-12-18 15:28:32 +08:00
}
const dirs = fs.readdirSync('.')
.filter(e => {
for (let bundle of bundles) {
if (bundle.match(new RegExp(`^${e}/`))) {
return true
}
}
return false
})
const allFiles = []
dirs.forEach(e => {
readDirs(e, allFiles)
})
export default allFiles
.map(e => e.replace('.ts', ''))
.map(bundle => {
return {
input: `build/${bundle}.js`,
output: {
format: "cjs",
file: `bundle/${bundle}.js`,
sourcemap: true,
},
plugins: [
resolve({ mainFields: ["jsnext"] }),
commonjs()
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
console.warn(warning.message);
}
}
})