fix: parse error on define
This commit is contained in:
parent
15e91251ac
commit
b4ab908ba2
3 changed files with 1029 additions and 948 deletions
1963
example/package-lock.json
generated
1963
example/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"@vitejs/plugin-react-refresh": "^1.1.0",
|
"@vitejs/plugin-react-refresh": "^1.1.0",
|
||||||
"typescript": "^4.1.2",
|
"typescript": "^4.1.2",
|
||||||
"vite": "^2.0.0-beta.69",
|
"vite": "^2.2.0",
|
||||||
"vite-plugin-package-version": "file:.."
|
"vite-plugin-package-version": "file:.."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -7,12 +7,10 @@ const createPlugin = (): Plugin => {
|
||||||
name: 'vite-plugin-package-version',
|
name: 'vite-plugin-package-version',
|
||||||
config: (_, env) => {
|
config: (_, env) => {
|
||||||
if (env) {
|
if (env) {
|
||||||
return {
|
const key = 'import.meta.env.PACKAGE_VERSION';
|
||||||
define: {
|
const val = JSON.stringify(process.env.npm_package_version);
|
||||||
['import.meta.env.PACKAGE_VERSION']:
|
|
||||||
process.env.npm_package_version,
|
return { define: { [key]: val } };
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
envInjectionFailed = true;
|
envInjectionFailed = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue