update rollup config

This commit is contained in:
pengfei.zhou 2019-12-18 15:28:32 +08:00
parent 2ccb2193d0
commit 4a8769684c
2 changed files with 53 additions and 35 deletions

View File

@ -1,24 +1,7 @@
export default [ export default [
'src/Counter', 'src/Counter',
'src/Snake', 'src/Snake',
'src/ListDemo',
'src/ScrollerDemo',
'src/SliderDemo',
'src/LayoutDemo',
'src/EffectsDemo',
'src/ImageDemo',
'src/ModalDemo',
'src/NetworkDemo',
'src/StorageDemo',
'src/NavigatorDemo',
'src/NavbarDemo',
'src/RefreshableDemo',
'src/FlowLayoutDemo',
'src/PopoverDemo',
'src/AnimatorDemo',
'src/ComplicatedAnimations', 'src/ComplicatedAnimations',
'src/ComplicatedDemo', 'src/.*Demo',
'src/InputDemo',
'src/StickDemo',
'src/Gobang', 'src/Gobang',
] ]

View File

@ -1,23 +1,58 @@
import resolve from 'rollup-plugin-node-resolve' import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs' import commonjs from 'rollup-plugin-commonjs'
import bundles from './build/index' import bundles from './build/index'
import fs from 'fs'
import path from 'path'
export default bundles.map(bundle => { function readDirs(dirPath, files) {
return { if (fs.statSync(dirPath).isDirectory()) {
input: `build/${bundle}.js`, fs.readdirSync(dirPath).forEach(e => {
output: { readDirs(path.join(dirPath, e), files)
format: "cjs", })
file: `bundle/${bundle}.js`, } else {
sourcemap: true, for (let bundle of bundles) {
}, if (dirPath.match(new RegExp(`^${bundle}`))) {
plugins: [ files.push(dirPath)
resolve({ mainFields: ["jsnext"] }), }
commonjs()
],
external: ['reflect-metadata', 'doric'],
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
console.warn(warning.message);
} }
} }
}) }
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);
}
}
})