Skip to content

Dynamic environment update#13

Open
NanatsuYorou wants to merge 5 commits intomasterfrom
dynamicEnvironmentUpdate
Open

Dynamic environment update#13
NanatsuYorou wants to merge 5 commits intomasterfrom
dynamicEnvironmentUpdate

Conversation

@NanatsuYorou
Copy link
Contributor

No description provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему rollup? Заголовок, команды установки.

А в Usage @37bytes/vite-

@@ -0,0 +1,44 @@
[//]: # (todo: уточнить название по конвенции)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo?

@@ -0,0 +1,17 @@
import { describe, expect, test } from '@jest/globals';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest? предлагаю перейти на vitest

import { join } from 'node:path';

describe('generate script', () => {
const path = join(process.cwd(), '__tests__/.env.test');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кажется, тут фикстуры нужны.
__fixtures__/.env.test вместо __tests__/.env.test

import { join } from 'node:path';

describe('get env variables from file', () => {
const path = join(process.cwd(), '__tests__/.env.test');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__fixtures__/.env.test вместо __tests__/.env.test

import { writeFileSync } from 'node:fs';
import { join, resolve } from 'node:path';

export const handleWriteBundle = ({ logger, forceEnvironmentScriptContent, outDir }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно выносить из тела плагина

@@ -0,0 +1,7 @@
export const handleTransformIndexHtml = ({ html, scriptLink }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно выносить из тела плагина


const createRequestHandler = ({ ignorePrefixes, envConfig, envDir }) => {
return (request, response) => {
console.warn('---------------------------');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.warn можно удалить, это артефакт разработки

@@ -0,0 +1,6 @@
// Генерирует js-строку, содержащую замороженный объект с переменными окружения
const generateScript = (environment: object) => `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавим сюда .trim()?

// import dotenv from "dotenv";
import { readFileSync } from 'node:fs';

const dotenv = require('dotenv');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предлагаю не смешивать import и require

Base automatically changed from vite-plugins to master April 3, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants