tiptap/build/package/config.js

94 lines
1.9 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
],
external: opts.external,
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-22 17:54:10 +08:00
input: resolve('src/index.js'),
2018-08-22 16:41:26 +08:00
file: resolve('dist/tiptap.js'),
format: 'umd',
env: 'development',
2018-08-22 17:54:10 +08:00
external: ['vue'],
2018-08-22 16:41:26 +08:00
},
{
2018-08-22 17:54:10 +08:00
input: resolve('src/index.js'),
2018-08-22 16:41:26 +08:00
file: resolve('dist/tiptap.min.js'),
format: 'umd',
env: 'production',
2018-08-22 17:54:10 +08:00
external: ['vue'],
2018-08-22 16:41:26 +08:00
},
{
2018-08-22 17:54:10 +08:00
input: resolve('src/index.js'),
2018-08-22 16:41:26 +08:00
file: resolve('dist/tiptap.common.js'),
format: 'cjs',
2018-08-22 17:54:10 +08:00
external: ['vue'],
2018-08-22 16:41:26 +08:00
},
{
2018-08-22 17:54:10 +08:00
input: resolve('src/index.js'),
2018-08-22 16:41:26 +08:00
file: resolve('dist/tiptap.esm.js'),
format: 'es',
2018-08-22 17:54:10 +08:00
external: ['vue'],
},
{
input: resolve('src/helpers/index.js'),
2018-08-22 19:06:59 +08:00
file: resolve('dist/helpers.min.js'),
2018-08-22 17:54:10 +08:00
format: 'umd',
env: 'development',
external: id => !/^[\.\/]/.test(id),
2018-08-22 16:41:26 +08:00
},
].map(genConfig)