ux-react can not run with assetmapper
langziyang opened this issue · comments
i follow the document,
1、create new symfony project: symfony new --webapp .
2、install ux-react bundle: composer require symfony/ux-react
3、yarn add @babel/preset-react --dev --force
4、created react.yaml with https://symfony.com/bundles/ux-react/current/index.html#using-with-asset-mapper
5、copy https://github.com/symfony/ux/blob/2.x/ux.symfony.com/package.json to my package.json
6、call react_component on twig file: <div {{ react_component('Hello') }}>
7、modify app.js
// assets/app.js
import { registerReactControllerComponents } from '@symfony/ux-react';
registerReactControllerComponents(require.context('./react/controllers', true, /\.(j|t)sx?$/));
8、run yarn build-react
9、run php bin/console asset-map:compile
then i get error message on DevTools "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec."
You should not use Yarn and AssetMapper at the same time; you have to choose which solution suits your project best.
Did you install StimulusBundle ?
sometimes woring,sometimes not working,i change it to encore now