fix: drop react-swc plugin for esbuild JSX and add vite-bundle routes
Use esbuild's built-in JSX transform instead of @vitejs/plugin-react-swc to fix the React Fast Refresh preamble error caused by eager glob imports. Add missing pentatrion_vite routes to fix web debug toolbar 500 errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1459,6 +1459,34 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* controllers_path?: scalar|null|Param, // The path to the directory where React controller components are stored - relevant only when using symfony/asset-mapper. // Default: "%kernel.project_dir%/assets/react/controllers"
|
* controllers_path?: scalar|null|Param, // The path to the directory where React controller components are stored - relevant only when using symfony/asset-mapper. // Default: "%kernel.project_dir%/assets/react/controllers"
|
||||||
* name_glob?: list<scalar|null|Param>,
|
* name_glob?: list<scalar|null|Param>,
|
||||||
* }
|
* }
|
||||||
|
* @psalm-type PentatrionViteConfig = array{
|
||||||
|
* public_directory?: scalar|null|Param, // Default: "public"
|
||||||
|
* build_directory?: scalar|null|Param, // we only need build_directory to locate entrypoints.json file, it's the "base" vite config parameter without slashes. // Default: "build"
|
||||||
|
* proxy_origin?: scalar|null|Param, // Allows to use different origin for asset proxy, eg. http://host.docker.internal:5173 // Default: null
|
||||||
|
* absolute_url?: bool|Param, // Prepend the rendered link and script tags with an absolute URL. // Default: false
|
||||||
|
* throw_on_missing_entry?: scalar|null|Param, // Throw exception when entry is not present in the entrypoints file // Default: false
|
||||||
|
* throw_on_missing_asset?: scalar|null|Param, // Throw exception when asset is not present in the manifest file // Default: true
|
||||||
|
* cache?: bool|Param, // Enable caching of the entry point file(s) // Default: false
|
||||||
|
* preload?: "none"|"link-tag"|"link-header"|Param, // preload all rendered script and link tags automatically via the http2 Link header. (symfony/web-link is required) Instead <link rel="modulepreload"> will be used. // Default: "link-tag"
|
||||||
|
* crossorigin?: false|true|"anonymous"|"use-credentials"|Param, // crossorigin value, can be false, true (default), anonymous (same as true) or use-credentials // Default: true
|
||||||
|
* script_attributes?: list<scalar|null|Param>,
|
||||||
|
* link_attributes?: list<scalar|null|Param>,
|
||||||
|
* preload_attributes?: list<scalar|null|Param>,
|
||||||
|
* default_build?: scalar|null|Param, // Deprecated: The "default_build" option is deprecated. Use "default_config" instead. // Default: null
|
||||||
|
* builds?: array<string, array{ // Default: []
|
||||||
|
* build_directory?: scalar|null|Param, // Default: "build"
|
||||||
|
* script_attributes?: list<scalar|null|Param>,
|
||||||
|
* link_attributes?: list<scalar|null|Param>,
|
||||||
|
* preload_attributes?: list<scalar|null|Param>,
|
||||||
|
* }>,
|
||||||
|
* default_config?: scalar|null|Param, // Default: null
|
||||||
|
* configs?: array<string, array{ // Default: []
|
||||||
|
* build_directory?: scalar|null|Param, // Default: "build"
|
||||||
|
* script_attributes?: list<scalar|null|Param>,
|
||||||
|
* link_attributes?: list<scalar|null|Param>,
|
||||||
|
* preload_attributes?: list<scalar|null|Param>,
|
||||||
|
* }>,
|
||||||
|
* }
|
||||||
* @psalm-type ConfigType = array{
|
* @psalm-type ConfigType = array{
|
||||||
* imports?: ImportsConfig,
|
* imports?: ImportsConfig,
|
||||||
* parameters?: ParametersConfig,
|
* parameters?: ParametersConfig,
|
||||||
@@ -1473,6 +1501,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* security?: SecurityConfig,
|
* security?: SecurityConfig,
|
||||||
* monolog?: MonologConfig,
|
* monolog?: MonologConfig,
|
||||||
* react?: ReactConfig,
|
* react?: ReactConfig,
|
||||||
|
* pentatrion_vite?: PentatrionViteConfig,
|
||||||
* "when@dev"?: array{
|
* "when@dev"?: array{
|
||||||
* imports?: ImportsConfig,
|
* imports?: ImportsConfig,
|
||||||
* parameters?: ParametersConfig,
|
* parameters?: ParametersConfig,
|
||||||
@@ -1490,6 +1519,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* monolog?: MonologConfig,
|
* monolog?: MonologConfig,
|
||||||
* maker?: MakerConfig,
|
* maker?: MakerConfig,
|
||||||
* react?: ReactConfig,
|
* react?: ReactConfig,
|
||||||
|
* pentatrion_vite?: PentatrionViteConfig,
|
||||||
* },
|
* },
|
||||||
* "when@prod"?: array{
|
* "when@prod"?: array{
|
||||||
* imports?: ImportsConfig,
|
* imports?: ImportsConfig,
|
||||||
@@ -1505,6 +1535,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* security?: SecurityConfig,
|
* security?: SecurityConfig,
|
||||||
* monolog?: MonologConfig,
|
* monolog?: MonologConfig,
|
||||||
* react?: ReactConfig,
|
* react?: ReactConfig,
|
||||||
|
* pentatrion_vite?: PentatrionViteConfig,
|
||||||
* },
|
* },
|
||||||
* "when@test"?: array{
|
* "when@test"?: array{
|
||||||
* imports?: ImportsConfig,
|
* imports?: ImportsConfig,
|
||||||
@@ -1521,6 +1552,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* security?: SecurityConfig,
|
* security?: SecurityConfig,
|
||||||
* monolog?: MonologConfig,
|
* monolog?: MonologConfig,
|
||||||
* react?: ReactConfig,
|
* react?: ReactConfig,
|
||||||
|
* pentatrion_vite?: PentatrionViteConfig,
|
||||||
* },
|
* },
|
||||||
* ...<string, ExtensionType|array{ // extra keys must follow the when@%env% pattern or match an extension alias
|
* ...<string, ExtensionType|array{ // extra keys must follow the when@%env% pattern or match an extension alias
|
||||||
* imports?: ImportsConfig,
|
* imports?: ImportsConfig,
|
||||||
|
|||||||
9
config/routes/pentatrion_vite.yaml
Normal file
9
config/routes/pentatrion_vite.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
when@dev:
|
||||||
|
_pentatrion_vite:
|
||||||
|
prefix: /build
|
||||||
|
resource: "@PentatrionViteBundle/Resources/config/routing.yaml"
|
||||||
|
|
||||||
|
_profiler_vite:
|
||||||
|
path: /_profiler/vite
|
||||||
|
defaults:
|
||||||
|
_controller: Pentatrion\ViteBundle\Controller\ProfilerController::info
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react-swc';
|
|
||||||
import symfonyPlugin from 'vite-plugin-symfony';
|
import symfonyPlugin from 'vite-plugin-symfony';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
react(),
|
symfonyPlugin({
|
||||||
symfonyPlugin(),
|
stimulus: true,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
|
esbuild: {
|
||||||
|
jsx: 'automatic',
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: {
|
input: {
|
||||||
@@ -23,6 +26,7 @@ export default defineConfig({
|
|||||||
hmr: {
|
hmr: {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 5173,
|
port: 5173,
|
||||||
|
protocol: 'ws',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user