2019-12-23 14:47:23 +08:00
|
|
|
import resolve from '@rollup/plugin-node-resolve'
|
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2019-12-04 14:16:57 +08:00
|
|
|
import bundles from './build/index'
|
2019-12-18 15:29:01 +08:00
|
|
|
import fs from 'fs'
|
|
|
|
import path from 'path'
|
2020-03-31 15:29:36 +08:00
|
|
|
//import babel from 'rollup-plugin-babel';
|
2020-03-27 15:52:33 +08:00
|
|
|
import json from '@rollup/plugin-json'
|
2019-12-04 14:16:57 +08:00
|
|
|
|
2019-12-18 15:29:01 +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:16:57 +08:00
|
|
|
}
|
2019-12-18 15:29:01 +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)
|
|
|
|
})
|
2020-01-17 17:10:01 +08:00
|
|
|
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(),
|
2020-03-27 15:52:33 +08:00
|
|
|
json(),
|
2020-01-17 17:10:01 +08:00
|
|
|
],
|
|
|
|
external: ['reflect-metadata', 'doric'],
|
|
|
|
onwarn: function (warning) {
|
|
|
|
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
|
|
|
|
console.warn(warning.message);
|
|
|
|
}
|
2019-12-18 15:29:01 +08:00
|
|
|
}
|
2020-03-27 15:52:33 +08:00
|
|
|
})
|
|
|
|
// If need ES5 support enable following configs
|
|
|
|
// .concat(
|
|
|
|
// allFiles
|
|
|
|
// .map(e => e.replace('.ts', ''))
|
|
|
|
// .map(bundle => {
|
|
|
|
// return {
|
|
|
|
// input: `build/${bundle}.js`,
|
|
|
|
// output: {
|
|
|
|
// format: "cjs",
|
|
|
|
// file: `bundle/${bundle}.es5.js`,
|
|
|
|
// sourcemap: true,
|
|
|
|
// },
|
|
|
|
// plugins: [
|
|
|
|
// resolve({ mainFields: ["jsnext"] }),
|
|
|
|
// commonjs(),
|
|
|
|
// buble({
|
|
|
|
// transforms: { dangerousForOf: true }
|
|
|
|
// }),
|
|
|
|
// ],
|
|
|
|
// external: ['reflect-metadata', 'doric'],
|
|
|
|
// onwarn: function (warning) {
|
|
|
|
// if (warning.code === 'THIS_IS_UNDEFINED') { return; }
|
|
|
|
// console.warn(warning.message);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }))
|