Skip to content

Commit

Permalink
vite-plugin-symfony : revert emptying outDir in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Apr 20, 2024
1 parent fe24ff4 commit 4fc80b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v6.4.4

- vite-plugin-symfony : fix typo in error message when outDir is outside project root (@acran)
- vite-plugin-symfony : revert emptying `outDir` in dev mode (thanks @nlemoine)

## v6.4.3

- vite-bundle : fix deprecation warning with `configs` key in multiple config.
Expand Down
2 changes: 1 addition & 1 deletion bin/php-cs-fixer
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
SCRIPT_DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")"
PROJECT_DIR=$(dirname "$SCRIPT_DIR")

/usr/bin/php8.1 $PROJECT_DIR/src/vite-bundle/vendor/bin/php-cs-fixer "$@"
/usr/bin/php8.2 $PROJECT_DIR/src/vite-bundle/vendor/bin/php-cs-fixer "$@"
4 changes: 2 additions & 2 deletions src/vite-bundle/src/Asset/ViteAssetVersionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ private function completeURL(string $path): string
private function getAssetPath(string $path): ?string
{
if (null === $this->viteMode) {
$this->viteMode = $this->fileAccessor->hasFile($this->configName, FileAccessor::MANIFEST) ? 'build' : 'dev';
$this->entrypointsData = $this->fileAccessor->getData($this->configName, FileAccessor::ENTRYPOINTS);
$this->viteMode = empty($this->entrypointsData['viteServer']) ? 'build' : 'dev';

$this->manifestData = 'build' === $this->viteMode ? $this->fileAccessor->getData($this->configName, FileAccessor::MANIFEST) : null;
$this->entrypointsData = $this->fileAccessor->getData($this->configName, FileAccessor::ENTRYPOINTS);
}

if ('build' === $this->viteMode) {
Expand Down
12 changes: 0 additions & 12 deletions src/vite-plugin-symfony/src/entrypoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getDevEntryPoints, getBuildEntryPoints, getFilesMetadatas } from "./ent
import {
normalizePath,
writeJson,
emptyDir,
isImportRequest,
isInternalRequest,
resolveDevServerUrl,
Expand All @@ -24,7 +23,6 @@ import {
getFileInfos,
getInputRelPath,
parseVersionString,
isSubdirectory,
extractExtraEnvVars,
} from "./utils";
import { resolveBase, resolveOutDir, refreshPaths, resolvePublicDir } from "../pluginOptions";
Expand Down Expand Up @@ -148,14 +146,6 @@ export default function symfonyEntrypoints(pluginOptions: VitePluginSymfonyEntry
const address = devServer.httpServer?.address();
const entryPointsPath = resolve(viteConfig.root, viteConfig.build.outDir, entryPointsFileName);

// buildDir is not a subdirectory of the vite project root -> potentially dangerous
if (!isSubdirectory(viteConfig.root, buildDir) && viteConfig.build.emptyOutDir !== true) {
logger.error(
`outDir ${buildDir} is not a subDirectory of your project root. To prevent recursively deleting files anywhere else set "build.emptyOutDir" to true in your vite.config.js to confirm that you did not accidentally specify a wrong directory location.`,
);
process.exit(1);
}

if (!isAddressInfo(address)) {
logger.error(
`address is not an object open an issue with your address value to fix the problem : ${address}`,
Expand All @@ -167,8 +157,6 @@ export default function symfonyEntrypoints(pluginOptions: VitePluginSymfonyEntry
mkdirSync(buildDir, { recursive: true });
}

existsSync(buildDir) && emptyDir(buildDir);

mkdirSync(viteDir, { recursive: true });

viteDevServerUrl = resolveDevServerUrl(address, devServer.config, pluginOptions);
Expand Down

0 comments on commit 4fc80b8

Please sign in to comment.