From 9633aafc018e4c26bc634af5d21c070cca03e125 Mon Sep 17 00:00:00 2001 From: yugasun Date: Thu, 22 Nov 2018 11:15:04 +0800 Subject: [PATCH] feat: add aio.min build --- config/rollup.config.aio.js | 35 ++++++++++++++++++++--------------- demo/camera.html | 2 +- demo/image.html | 8 ++++---- demo/index.aio.js | 7 ------- demo/index.aio.min.js | 7 +++++++ demo/video.html | 2 +- package.json | 7 ++++--- 7 files changed, 37 insertions(+), 31 deletions(-) delete mode 100644 demo/index.aio.js create mode 100644 demo/index.aio.min.js diff --git a/config/rollup.config.aio.js b/config/rollup.config.aio.js index e4cce05..e8fb6ee 100644 --- a/config/rollup.config.aio.js +++ b/config/rollup.config.aio.js @@ -6,10 +6,12 @@ import commonjs from 'rollup-plugin-commonjs'; import { uglify } from 'rollup-plugin-uglify'; import common from './rollup'; +const prod = process.env.NODE_ENV; + export default { input: 'src/index.js', output: { - file: 'dist/index.aio.js', + file: prod ? 'dist/index.aio.min.js' : 'dist/index.aio.js', format: 'umd', // 如果不同时使用 export 与 export default 可打开legacy // legacy: true, @@ -28,20 +30,23 @@ export default { runtimeHelpers: true, exclude: 'node_modules/**', }), - uglify({ - compress: { - drop_debugger: true, - drop_console: true, - }, - output: { - comments: (node, comment) => { - if (comment.type === 'comment2') { - // multiline comment - return /@preserve|@license|@cc_on/i.test(comment.value); - } - return false; + prod && + uglify({ + compress: { + drop_debugger: true, + drop_console: true, }, - }, - }), + output: { + comments: (node, comment) => { + if (comment.type === 'comment2') { + // multiline comment + return /@preserve|@license|@cc_on/i.test( + comment.value, + ); + } + return false; + }, + }, + }), ], }; diff --git a/demo/camera.html b/demo/camera.html index c9011f5..6670543 100644 --- a/demo/camera.html +++ b/demo/camera.html @@ -9,7 +9,7 @@
- + + qr code + +