Add vite-plugin-node to be able to run API locally
This commit is contained in:
parent
03f49e4056
commit
40c0add0e3
3 changed files with 49 additions and 3 deletions
|
@ -34,7 +34,8 @@
|
||||||
"sass": "^1.49.7",
|
"sass": "^1.49.7",
|
||||||
"svgo": "^3.0.1",
|
"svgo": "^3.0.1",
|
||||||
"terser": "^5.16.6",
|
"terser": "^5.16.6",
|
||||||
"vite": "^4.1.4"
|
"vite": "^4.1.4",
|
||||||
|
"vite-plugin-node": "^3.0.2"
|
||||||
},
|
},
|
||||||
"postcss": {
|
"postcss": {
|
||||||
"map": true,
|
"map": true,
|
||||||
|
|
|
@ -14,6 +14,7 @@ specifiers:
|
||||||
svgo: ^3.0.1
|
svgo: ^3.0.1
|
||||||
terser: ^5.16.6
|
terser: ^5.16.6
|
||||||
vite: ^4.1.4
|
vite: ^4.1.4
|
||||||
|
vite-plugin-node: ^3.0.2
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@vitejs/plugin-legacy': 4.0.2_terser@5.16.6+vite@4.1.4
|
'@vitejs/plugin-legacy': 4.0.2_terser@5.16.6+vite@4.1.4
|
||||||
|
@ -29,6 +30,7 @@ devDependencies:
|
||||||
svgo: 3.0.2
|
svgo: 3.0.2
|
||||||
terser: 5.16.6
|
terser: 5.16.6
|
||||||
vite: 4.1.4_sass@1.49.7+terser@5.16.6
|
vite: 4.1.4_sass@1.49.7+terser@5.16.6
|
||||||
|
vite-plugin-node: 3.0.2_vite@4.1.4
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
@ -1502,6 +1504,14 @@ packages:
|
||||||
fastq: 1.15.0
|
fastq: 1.15.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@rollup/pluginutils/4.2.1:
|
||||||
|
resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==}
|
||||||
|
engines: {node: '>= 8.0.0'}
|
||||||
|
dependencies:
|
||||||
|
estree-walker: 2.0.2
|
||||||
|
picomatch: 2.3.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@trysound/sax/0.2.0:
|
/@trysound/sax/0.2.0:
|
||||||
resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==}
|
resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==}
|
||||||
engines: {node: '>=10.13.0'}
|
engines: {node: '>=10.13.0'}
|
||||||
|
@ -2119,7 +2129,11 @@ packages:
|
||||||
engines: {node: '>=4.0'}
|
engines: {node: '>=4.0'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/esutils@2.0.3:
|
/estree-walker/2.0.2:
|
||||||
|
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/esutils/2.0.3:
|
||||||
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
|
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -3052,6 +3066,23 @@ packages:
|
||||||
spdx-expression-parse: 3.0.1
|
spdx-expression-parse: 3.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vite-plugin-node/3.0.2_vite@4.1.4:
|
||||||
|
resolution: {integrity: sha512-pA/QZDe4VRFUSChTrR64EfdsnwHbTnkXKx1Be8MP2oW43TPeQgtIfqiGOuXTPUKjwINtyEl8JMzRN0+dYyfTow==}
|
||||||
|
peerDependencies:
|
||||||
|
'@swc/core': ^1.2.153
|
||||||
|
vite: ^4.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@swc/core':
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@rollup/pluginutils': 4.2.1
|
||||||
|
chalk: 4.1.2
|
||||||
|
debug: 4.3.4
|
||||||
|
vite: 4.1.4_sass@1.49.7+terser@5.16.6
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vite/4.1.4_sass@1.49.7+terser@5.16.6:
|
/vite/4.1.4_sass@1.49.7+terser@5.16.6:
|
||||||
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
|
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import legacy from "@vitejs/plugin-legacy";
|
import legacy from "@vitejs/plugin-legacy";
|
||||||
|
import { VitePluginNode } from "vite-plugin-node";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
build: {
|
build: {
|
||||||
|
@ -6,5 +7,18 @@ export default {
|
||||||
terserOptions: { ecma: 5 },
|
terserOptions: { ecma: 5 },
|
||||||
sourcemap: "true",
|
sourcemap: "true",
|
||||||
},
|
},
|
||||||
plugins: [legacy()],
|
plugins: [
|
||||||
|
legacy(),
|
||||||
|
VitePluginNode({
|
||||||
|
// Workaround from: https://github.com/axe-me/vite-plugin-node/issues/47
|
||||||
|
adapter({ app, req, res, next }) {
|
||||||
|
if (req.url.startsWith("/api/")) {
|
||||||
|
app(req, res);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appPath: "./api/share.js",
|
||||||
|
}),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue