chore: build axios-fetch for test

This commit is contained in:
Nex Zhu 2023-03-18 19:55:44 +08:00
parent ec5099762e
commit 92129afd38
No known key found for this signature in database
GPG Key ID: 15C6254AD19362B4
3 changed files with 134 additions and 120 deletions

View File

@ -43,7 +43,6 @@
"prettier": "^2.7.1", "prettier": "^2.7.1",
"rollup": "^2.79.1", "rollup": "^2.79.1",
"rollup-plugin-dts": "^4.2.2", "rollup-plugin-dts": "^4.2.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1", "rollup-plugin-typescript2": "^0.34.1",
"shx": "^0.3.4", "shx": "^0.3.4",

View File

@ -1,14 +1,23 @@
import type { RollupOptions } from '@rollup' import type { RollupOptions } from '@rollup'
import commonjs from '@rollup/plugin-commonjs'
import dts from 'rollup-plugin-dts' import dts from 'rollup-plugin-dts'
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import typescript from 'rollup-plugin-typescript2' import typescript from 'rollup-plugin-typescript2'
import commonjs from '@rollup/plugin-commonjs'
const pkg = require('./package.json') const pkg = require('./package.json')
const name = 'bdcontract' const name = 'bdcontract'
export default [ export default [
{
input: 'node_modules/@lifeomic/axios-fetch/src/index.js',
output: {
file: 'dist/axios-fetch.iife.js',
format: 'iife',
name: 'axiosFetch',
},
plugins: [commonjs()],
},
{ {
input: 'src/index.ts', input: 'src/index.ts',
output: [ output: [
@ -17,12 +26,12 @@ export default [
format: 'umd', format: 'umd',
name, name,
sourcemap: true, sourcemap: true,
globals:{ globals: {
"@daotl/cryptico":"cryptico", '@daotl/cryptico': 'cryptico',
"@lifeomic/axios-fetch":"axiosFetch", '@lifeomic/axios-fetch': 'axiosFetch',
"axios":"axios", axios: 'axios',
"sm-crypto":"smCrypto" 'sm-crypto': 'smCrypto',
} },
}, },
{ file: `${pkg.module}`, format: 'es', sourcemap: true }, { file: `${pkg.module}`, format: 'es', sourcemap: true },
{ {
@ -30,12 +39,12 @@ export default [
format: 'iife', format: 'iife',
name, name,
sourcemap: true, sourcemap: true,
globals:{ globals: {
"@daotl/cryptico":"cryptico", '@daotl/cryptico': 'cryptico',
"@lifeomic/axios-fetch":"axiosFetch", '@lifeomic/axios-fetch': 'axiosFetch',
"axios":"axios", axios: 'axios',
"sm-crypto":"smCrypto" 'sm-crypto': 'smCrypto',
} },
}, },
], ],
plugins: [ plugins: [
@ -43,7 +52,8 @@ export default [
tsconfig: 'tsconfig.build.json', tsconfig: 'tsconfig.build.json',
useTsconfigDeclarationDir: true, useTsconfigDeclarationDir: true,
}), }),
terser(),commonjs() terser(),
commonjs(),
], ],
}, },
{ {

View File

@ -1,18 +1,21 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<!-- <script src="../node_modules/cross-fetch/dist/cross-fetch.js"></script> --> <!-- <script src="../node_modules/cross-fetch/dist/cross-fetch.js"></script> -->
<script src="../lib/index.js"></script>
<script src="./sm2.js"></script> <script src="./sm2.js"></script>
<script src="./cryptico.iife.js"></script> <script src="./cryptico.iife.js"></script>
<script src="https://unpkg.com/axios@1.3.4/dist/axios.min.js"></script>
<script src="../dist/axios-fetch.iife.js"></script>
<script src="../lib/index.js"></script>
<!-- <script src="../dist/bdcontract-sdk.iife.js"></script> --> <!-- <script src="../dist/bdcontract-sdk.iife.js"></script> -->
<script> <script>
function print(string) { function print(string) {
document.write(`${string}\n\n`) document.write(`${string}\n\n`)
} }
;(async () => { ; (async () => {
// const url = 'http://021.node.internetapi.cn:18010/SCIDE' // const url = 'http://021.node.internetapi.cn:18010/SCIDE'
// const url = 'http://022.node.internetapi.cn:18010/SCIDE' // const url = 'http://022.node.internetapi.cn:18010/SCIDE'
const url = 'http://041.node.internetapi.cn:21030/SCIDE/SCIDE' const url = 'http://041.node.internetapi.cn:21030/SCIDE/SCIDE'
@ -105,6 +108,8 @@
<link rel="icon" type="image/svg+xml" href="favicon.svg" /> <link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title> <title>Vite App</title>
</head> </head>
<body></body>
<body></body>
</html> </html>