mirror of
https://github.com/Instadapp/vue-web3.git
synced 2024-07-29 21:48:25 +00:00
Add nuxt module
This commit is contained in:
parent
a4178e79d2
commit
69c4722d37
12
nuxt/.editorconfig
Normal file
12
nuxt/.editorconfig
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
2
nuxt/.eslintignore
Normal file
2
nuxt/.eslintignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
dist
|
||||
node_modules
|
||||
10
nuxt/.eslintrc
Normal file
10
nuxt/.eslintrc
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": [
|
||||
"@nuxtjs/eslint-config-typescript"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"off"
|
||||
]
|
||||
}
|
||||
}
|
||||
51
nuxt/.gitignore
vendored
Normal file
51
nuxt/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# Dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
*.log*
|
||||
|
||||
# Temp directories
|
||||
.temp
|
||||
.tmp
|
||||
.cache
|
||||
|
||||
# Yarn
|
||||
**/.yarn/cache
|
||||
**/.yarn/*state*
|
||||
|
||||
# Generated dirs
|
||||
dist
|
||||
|
||||
# Nuxt
|
||||
.nuxt
|
||||
.output
|
||||
.vercel_build_output
|
||||
.build-*
|
||||
.env
|
||||
.netlify
|
||||
|
||||
# Env
|
||||
.env
|
||||
|
||||
# Testing
|
||||
reports
|
||||
coverage
|
||||
*.lcov
|
||||
.nyc_output
|
||||
|
||||
# VSCode
|
||||
.vscode
|
||||
|
||||
# Intellij idea
|
||||
*.iml
|
||||
.idea
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
6
nuxt/README.md
Normal file
6
nuxt/README.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Nuxt Module
|
||||
|
||||
## Development
|
||||
|
||||
- Run `npm run dev:prepare` to generate type stubs.
|
||||
- Use `npm run dev` to start [playground](./playground) in development mode.
|
||||
36
nuxt/package.json
Normal file
36
nuxt/package.json
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "@instadapp/vue-web3-nuxt",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/module.mjs",
|
||||
"require": "./dist/module.cjs"
|
||||
}
|
||||
},
|
||||
"main": "./dist/module.cjs",
|
||||
"types": "./dist/types.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prepack": "nuxt-module-build",
|
||||
"dev": "nuxi dev playground",
|
||||
"dev:build": "nuxi build playground",
|
||||
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground"
|
||||
},
|
||||
"dependencies": {
|
||||
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
||||
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
||||
"@instadapp/vue-web3": "^0.7.0",
|
||||
"@nuxt/kit": "^3.0.0-rc.3",
|
||||
"rollup-plugin-node-polyfills": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/module-builder": "latest",
|
||||
"@nuxtjs/eslint-config-typescript": "latest",
|
||||
"eslint": "latest",
|
||||
"nuxt": "^3.0.0-rc.3"
|
||||
}
|
||||
}
|
||||
45
nuxt/playground/app.vue
Normal file
45
nuxt/playground/app.vue
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<template>
|
||||
<div class="relative p-10 n-bg-base">
|
||||
<div class="container w-full mx-auto flex flex-col gap-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="text-4xl">
|
||||
Web3 + Nuxt
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NCard class="p4">
|
||||
<pre>{{ {account, active, error} }}</pre>
|
||||
</NCard>
|
||||
|
||||
<NCard class="p4 flex gap-4">
|
||||
<NButton @click="connectMetamask">
|
||||
Connect using MetaMask
|
||||
</NButton>
|
||||
|
||||
<NButton @click="connectWalletConnect">
|
||||
Connect using WalletConnect
|
||||
</NButton>
|
||||
</NCard>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const { active, account, activate, error } = useWeb3()
|
||||
|
||||
const connectMetamask = async () => {
|
||||
const { InjectedConnector } = await import('@web3-react/injected-connector')
|
||||
|
||||
await activate(
|
||||
new InjectedConnector({})
|
||||
)
|
||||
}
|
||||
|
||||
const connectWalletConnect = async () => {
|
||||
const { WalletConnectConnector } = await import('@web3-react/walletconnect-connector')
|
||||
|
||||
await activate(
|
||||
new WalletConnectConnector({ })
|
||||
)
|
||||
}
|
||||
</script>
|
||||
12
nuxt/playground/nuxt.config.ts
Normal file
12
nuxt/playground/nuxt.config.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { defineNuxtConfig } from 'nuxt'
|
||||
import MyModule from '..'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
'@nuxt/ui',
|
||||
MyModule
|
||||
],
|
||||
|
||||
web3: {
|
||||
}
|
||||
})
|
||||
11
nuxt/playground/package.json
Normal file
11
nuxt/playground/package.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "my-module-playground",
|
||||
"dependencies": {
|
||||
"@web3-react/injected-connector": "^6.0.7",
|
||||
"@web3-react/walletconnect-connector": "^6.2.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/ui": "^0.1.1"
|
||||
}
|
||||
}
|
||||
2275
nuxt/playground/yarn.lock
Normal file
2275
nuxt/playground/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
54
nuxt/src/module.ts
Normal file
54
nuxt/src/module.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import { resolve } from 'path'
|
||||
import { addAutoImport, defineNuxtModule, extendViteConfig } from '@nuxt/kit'
|
||||
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
|
||||
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
|
||||
|
||||
export interface ModuleOptions {
|
||||
autoImport: boolean
|
||||
}
|
||||
|
||||
export default defineNuxtModule<ModuleOptions>({
|
||||
meta: {
|
||||
name: 'vue-web3',
|
||||
configKey: 'web3'
|
||||
},
|
||||
defaults: {
|
||||
autoImport: true
|
||||
},
|
||||
setup (options, nuxt) {
|
||||
nuxt.hook('vite:extendConfig', (clientConfig, { isClient }) => {
|
||||
if (isClient && process.env.NODE_ENV === 'production') {
|
||||
clientConfig.resolve.alias = {
|
||||
...clientConfig.resolve.alias,
|
||||
web3: resolve('./node_modules/web3/dist/web3.min.js')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
extendViteConfig((config) => {
|
||||
config.build = config.build || {}
|
||||
config.build.rollupOptions = config.build.rollupOptions || {}
|
||||
config.build.rollupOptions.plugins = config.build.rollupOptions.plugins || []
|
||||
config.build.rollupOptions.plugins.push(rollupNodePolyFill())
|
||||
|
||||
config.optimizeDeps = config.optimizeDeps || {}
|
||||
config.optimizeDeps.esbuildOptions = config.optimizeDeps.esbuildOptions || {}
|
||||
config.optimizeDeps.esbuildOptions.define = config.optimizeDeps.esbuildOptions.define || {}
|
||||
config.optimizeDeps.esbuildOptions.define.global = 'globalThis'
|
||||
|
||||
config.optimizeDeps.esbuildOptions.plugins = config.optimizeDeps.esbuildOptions.plugins || []
|
||||
config.optimizeDeps.esbuildOptions.plugins.push(
|
||||
NodeGlobalsPolyfillPlugin({
|
||||
process: true,
|
||||
buffer: true
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
if (options.autoImport) {
|
||||
addAutoImport({
|
||||
name: 'useWeb3', from: '@instadapp/vue-web3'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
3
nuxt/tsconfig.json
Normal file
3
nuxt/tsconfig.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "./playground/.nuxt/tsconfig.json"
|
||||
}
|
||||
5960
nuxt/yarn.lock
Normal file
5960
nuxt/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@instadapp/vue-web3",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"description": "Vue web3 composition api",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
"lint:fix": "yarn run lint --write"
|
||||
},
|
||||
"files": [
|
||||
"nuxt/**/*",
|
||||
"dist/**/*",
|
||||
"index.js",
|
||||
"index.cjs",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user