-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Eric Fennis <[email protected]>
- Loading branch information
1 parent
ed9db67
commit dbb2cf1
Showing
6 changed files
with
415 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import fs from 'fs'; | ||
import module from 'node:module'; | ||
/* WASM_IMPORT */ | ||
|
||
let wasm; | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
const require = module.createRequire(import.meta.url); | ||
|
||
wasm = fs.readFileSync(require.resolve('@resvg/resvg-wasm/index_bg.wasm')); | ||
} else { | ||
wasm = resvg_wasm; | ||
} | ||
|
||
export default wasm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
declare module "*.vue" { | ||
import Vue from "vue"; | ||
declare module '*.vue' { | ||
import Vue from 'vue'; | ||
export default Vue; | ||
} | ||
|
||
declare module "*.data.ts" { | ||
declare module '*.data.ts' { | ||
const data: any; | ||
|
||
export { data }; | ||
} | ||
|
||
declare module '*.wasm' {} | ||
|
||
declare const resvg_wasm: RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
|
||
declare module 'node:module' { | ||
function createRequire(filename: string): NodeRequire; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import { defineNitroConfig } from "nitropack"; | ||
import copy from 'rollup-plugin-copy'; | ||
import replace from '@rollup/plugin-replace'; | ||
|
||
export default defineNitroConfig({ | ||
preset: 'vercel-edge', | ||
srcDir: '.vitepress', | ||
routeRules: { | ||
'/api/**': { cors: false }, | ||
}, | ||
rollupConfig: { | ||
external: ['@resvg/resvg-wasm/index_bg.wasm', './index_bg.wasm?module'], | ||
plugins: [ | ||
copy({ | ||
targets: [ | ||
{ | ||
src: './node_modules/@resvg/resvg-wasm/index_bg.wasm', | ||
dest: './.vercel/output/functions/__nitro.func', | ||
}, | ||
], | ||
}), | ||
replace({ | ||
include: ['./**/*.ts'], | ||
'/* WASM_IMPORT */': 'import resvg_wasm from "./index_bg.wasm?module";', | ||
delimiters: ['', ''], | ||
preventAssignment: false, | ||
}), | ||
], | ||
}, | ||
esbuild: { | ||
options: { | ||
include: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.json'], | ||
loaders: { | ||
'.js': 'js', | ||
'.jsx': 'jsx', | ||
'.ts': 'ts', | ||
'.tsx': 'tsx', | ||
} | ||
jsxFactory: 'React.createElement', | ||
jsxFragment: 'React.Fragment', | ||
}, | ||
}, | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.