-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove
define
of process.env
from base config
Removing `process.env` is only required for apps, as we now build apps not in lib mode it is removed automatically by vite Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
8 changed files
with
56 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2023 Ferdinand Thiessen <opensource@fthiessen.de> | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
coverage/ | ||
dist/ | ||
node_modules/ | ||
js/ |
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
2 changes: 2 additions & 0 deletions
2
__fixtures__/app_process_env/js/@nextcloud-vite-config-main.mjs
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,2 @@ | ||
/*! third party licenses: js/vendor.LICENSE.txt */ | ||
window.my_timezone={}.TZ; | ||
1 change: 1 addition & 0 deletions
1
__fixtures__/app_process_env/js/@nextcloud-vite-config-main.mjs.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2023 Ferdinand Thiessen <opensource@fthiessen.de> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
window.my_timezone = process.env.TZ | ||
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,7 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`app config > replaces process.env 1`] = ` | ||
"/*! third party licenses: js/vendor.LICENSE.txt */ | ||
window.my_timezone={}.TZ; | ||
" | ||
`; |
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,35 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2023 Ferdinand Thiessen <opensource@fthiessen.de> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { build } from 'vite' | ||
// ok as this is just for tests | ||
// eslint-disable-next-line n/no-extraneous-import | ||
import type { RollupOutput, OutputChunk } from 'rollup' | ||
import { describe, it, expect } from 'vitest' | ||
import { createAppConfig } from '../lib/appConfig' | ||
import { fileURLToPath } from 'url' | ||
import { resolve } from 'path' | ||
|
||
const __dirname = fileURLToPath(new URL('.', import.meta.url)) | ||
|
||
describe('app config', () => { | ||
it('replaces process.env', async () => { | ||
const root = resolve(__dirname, '../__fixtures__/app_process_env') | ||
|
||
const resolved = await createAppConfig({ | ||
main: resolve(root, 'main.js'), | ||
})({ command: 'build', mode: 'production' }) | ||
|
||
const result = await build({ | ||
...resolved, | ||
root, | ||
}) | ||
const { output } = result as RollupOutput | ||
const code = (output[0] as OutputChunk).code | ||
expect(code.includes('process.env')).toBe(false) | ||
expect(code).toMatchSnapshot() | ||
}) | ||
}) |
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