mirror of
https://github.com/yugasun/qrcode-decoder.git
synced 2026-08-12 20:27:56 +08:00
feat: add aio.min build
This commit is contained in:
+20
-15
@@ -6,10 +6,12 @@ import commonjs from 'rollup-plugin-commonjs';
|
|||||||
import { uglify } from 'rollup-plugin-uglify';
|
import { uglify } from 'rollup-plugin-uglify';
|
||||||
import common from './rollup';
|
import common from './rollup';
|
||||||
|
|
||||||
|
const prod = process.env.NODE_ENV;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: 'src/index.js',
|
input: 'src/index.js',
|
||||||
output: {
|
output: {
|
||||||
file: 'dist/index.aio.js',
|
file: prod ? 'dist/index.aio.min.js' : 'dist/index.aio.js',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
// 如果不同时使用 export 与 export default 可打开legacy
|
// 如果不同时使用 export 与 export default 可打开legacy
|
||||||
// legacy: true,
|
// legacy: true,
|
||||||
@@ -28,20 +30,23 @@ export default {
|
|||||||
runtimeHelpers: true,
|
runtimeHelpers: true,
|
||||||
exclude: 'node_modules/**',
|
exclude: 'node_modules/**',
|
||||||
}),
|
}),
|
||||||
uglify({
|
prod &&
|
||||||
compress: {
|
uglify({
|
||||||
drop_debugger: true,
|
compress: {
|
||||||
drop_console: true,
|
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;
|
|
||||||
},
|
},
|
||||||
},
|
output: {
|
||||||
}),
|
comments: (node, comment) => {
|
||||||
|
if (comment.type === 'comment2') {
|
||||||
|
// multiline comment
|
||||||
|
return /@preserve|@license|@cc_on/i.test(
|
||||||
|
comment.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<video id="video" autoplay></video>
|
<video id="video" autoplay></video>
|
||||||
|
|
||||||
<script src="./index.aio.js"></script>
|
<script src="./index.aio.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function main() {
|
function main() {
|
||||||
var qr = new QrcodeDecoder();
|
var qr = new QrcodeDecoder();
|
||||||
|
|||||||
+4
-4
@@ -7,8 +7,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<button id="decode">Decode!</button><br>
|
<button id="decode">Decode!</button><br>
|
||||||
<span id="result"></span><br>
|
<span id="result"></span><br>
|
||||||
<!-- <img src="./assets/qrcode.png" alt="qr code" /> -->
|
<img src="./assets/qrcode.png" alt="qr code" />
|
||||||
<script src="./index.aio.js"></script>
|
<script src="./index.aio.min.js"></script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
function main() {
|
function main() {
|
||||||
var qr = new QrcodeDecoder();
|
var qr = new QrcodeDecoder();
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
btn.onclick = async () => {
|
btn.onclick = async () => {
|
||||||
// you can also decode from image path
|
// you can also decode from image path
|
||||||
const code = await qr.decodeFromImage('./assets/qrcode.png');
|
// const code = await qr.decodeFromImage('./assets/qrcode.png');
|
||||||
// const code = qr.decodeFromImage(img);
|
const code = await qr.decodeFromImage(img);
|
||||||
console.log(code);
|
console.log(code);
|
||||||
result.innerText = code.data;
|
result.innerText = code.data;
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Vendored
+7
File diff suppressed because one or more lines are too long
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<video src="./assets/qrcode-video.mp4"></video>
|
<video src="./assets/qrcode-video.mp4"></video>
|
||||||
|
|
||||||
<script src="./index.aio.js"></script>
|
<script src="./index.aio.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function main() {
|
function main() {
|
||||||
var video = document.querySelector('video');
|
var video = document.querySelector('video');
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "qrcode-decoder",
|
"name": "qrcode-decoder",
|
||||||
"version": "1.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Tool for decoding qrcode",
|
"description": "Tool for decoding qrcode",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"jsnext:main": "dist/index.esm.js",
|
"jsnext:main": "dist/index.esm.js",
|
||||||
@@ -12,8 +12,9 @@
|
|||||||
"build:self": "rollup -c config/rollup.config.js",
|
"build:self": "rollup -c config/rollup.config.js",
|
||||||
"build:esm": "rollup -c config/rollup.config.esm.js",
|
"build:esm": "rollup -c config/rollup.config.esm.js",
|
||||||
"build:aio": "rollup -c config/rollup.config.aio.js",
|
"build:aio": "rollup -c config/rollup.config.aio.js",
|
||||||
"build": "npm run clean && npm run build:self && npm run build:esm && npm run build:aio && npm run copy-file",
|
"build:aio.min": "NODE_ENV=production npm run build:aio",
|
||||||
"copy-file": "cp dist/index.aio.js demo/",
|
"build": "npm run clean && npm run build:self && npm run build:esm && npm run build:aio && npm run build:aio.min && npm run copy-file",
|
||||||
|
"copy-file": "cp dist/index.aio.min.js demo/",
|
||||||
"test": "npm run lint && npm run build",
|
"test": "npm run lint && npm run build",
|
||||||
"zuul-test": "zuul --local 8080 --ui mocha-bdd -- test/test.js",
|
"zuul-test": "zuul --local 8080 --ui mocha-bdd -- test/test.js",
|
||||||
"release": "git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags",
|
"release": "git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags",
|
||||||
|
|||||||
Reference in New Issue
Block a user