diff --git a/copyright.js b/copyright.js new file mode 100644 index 0000000..4fb99e1 --- /dev/null +++ b/copyright.js @@ -0,0 +1,9 @@ +import { version } from './package.json' + +export default `/** + * Anot.js -- an mini mvvm framework + * @author yutent + * @date 2020/08/13 15:26:11 + * @version ${version} + */ +` diff --git a/lib/plugin.esm.js b/lib/plugin.esm.js new file mode 100644 index 0000000..307f3bb --- /dev/null +++ b/lib/plugin.esm.js @@ -0,0 +1,19 @@ +/** + * rollup plugin + * @author yutent + * @date 2020/08/11 15:46:57 + */ + +export default function esm() { + return { + name: 'esm', + generateBundle(info, chunk) { + var item + for (let k in chunk) { + item = chunk[k] + break + } + item.code += 'export default _Anot\n' + } + } +} diff --git a/rollup.config.dev.js b/rollup.config.dev.js index f160c52..94fe208 100644 --- a/rollup.config.dev.js +++ b/rollup.config.dev.js @@ -1,22 +1,30 @@ -// const uglify = require('@bytedo/rollup-plugin-uglify') +/** + * 开发版配置 + * @author yutent + * @date 2020/08/13 15:28:39 + */ -module.exports = [ +import esm from './lib/plugin.esm' + +export default [ { input: 'src/anot.js', output: { file: 'dist/anot.js', - format: 'es', - sourcemap: false + format: 'iife', + sourcemap: true, + name: '_Anot' }, - plugins: [] + plugins: [esm()] }, { input: 'src/anot.touch.js', output: { file: 'dist/anot.touch.js', - format: 'es', - sourcemap: false + format: 'iife', + sourcemap: true, + name: '_Anot' }, - plugins: [] + plugins: [esm()] } ] diff --git a/rollup.config.prod.js b/rollup.config.prod.js index 9087c71..11dc447 100644 --- a/rollup.config.prod.js +++ b/rollup.config.prod.js @@ -1,22 +1,32 @@ -const uglify = require('@bytedo/rollup-plugin-uglify') +/** + * 生产版配置 + * @author yutent + * @date 2020/08/13 15:28:39 + */ -module.exports = [ +import uglify from '@bytedo/rollup-plugin-uglify' +import esm from './lib/plugin.esm' +import copyright from './copyright' + +export default [ { input: 'src/anot.js', output: { file: 'dist/anot.js', - format: 'es', - sourcemap: false + format: 'iife', + banner: copyright, + name: '_Anot' }, - plugins: [uglify()] + plugins: [esm(), uglify()] }, { input: 'src/anot.touch.js', output: { file: 'dist/anot.touch.js', - format: 'es', - sourcemap: false + format: 'iife', + banner: copyright, + name: '_Anot' }, - plugins: [uglify()] + plugins: [esm(), uglify()] } ]