tiptap/build/packages/config.js

104 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-08-22 16:41:26 +08:00
import path from 'path'
import vue from 'rollup-plugin-vue'
import buble from 'rollup-plugin-buble'
import flow from 'rollup-plugin-flow-no-whitespace'
import cjs from 'rollup-plugin-commonjs'
import node from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import packagejson from '../../package.json'
const { version } = packagejson
const banner = `
/*!
* tiptap v${version}
* (c) ${new Date().getFullYear()} Scrumpy UG (limited liability)
* @license MIT
*/
`
const resolve = _path => path.resolve(__dirname, '../../', _path)
function genConfig(opts) {
const config = {
input: {
2018-08-22 17:54:10 +08:00
input: opts.input,
2018-08-22 16:41:26 +08:00
plugins: [
flow(),
node(),
cjs(),
vue({
css: true,
compileTemplate: true,
}),
replace({
__VERSION__: version,
}),
buble({
objectAssign: 'Object.assign',
}),
2018-08-22 17:54:10 +08:00
],
2018-08-26 14:31:43 +08:00
external(id) { return !/^[\.\/]/.test(id) },
2018-08-22 16:41:26 +08:00
},
output: {
file: opts.file,
format: opts.format,
banner,
name: 'tiptap',
},
}
if (opts.env) {
config.input.plugins.unshift(replace({
'process.env.NODE_ENV': JSON.stringify(opts.env),
}))
}
return config
}
export default [
2018-08-23 17:23:03 +08:00
{
2018-08-26 17:55:52 +08:00
package: 'tiptap',
outputFileName: 'tiptap',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-commands',
outputFileName: 'commands',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-utils',
outputFileName: 'utils',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-extensions',
outputFileName: 'extensions',
2018-08-23 17:23:03 +08:00
},
2018-08-26 17:55:52 +08:00
].map(item => [
2018-08-23 17:23:03 +08:00
{
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.js`),
2018-08-24 04:09:38 +08:00
format: 'umd',
env: 'development',
},
{
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.min.js`),
2018-08-24 04:09:38 +08:00
format: 'umd',
env: 'production',
},
{
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.common.js`),
2018-08-24 04:09:38 +08:00
format: 'cjs',
},
{
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.esm.js`),
2018-08-24 04:09:38 +08:00
format: 'es',
2018-08-26 17:55:52 +08:00
}])
.reduce((allConfigs, configs) => ([
...allConfigs,
...configs,
]), [])
.map(genConfig)