Как я могу отобразить несколько тегов encore_entry_script_tags - PullRequest
0 голосов
/ 19 июня 2020

Я хочу отобразить указанный c компонент реакции из приложения реакции в приложение Symfony v 4.16.1.

Я использую wepack encore.

файл ветки

{% extends 'layout.html.twig' %}

{% block css %}
  {{ parent() }}
  {{ encore_entry_link_tags('mypage') }}

{% endblock %}

{% block content %}
  <div id="root"></div>
    <div id="mypage"></div>

{% endblock %}

{% block javascripts %}
  {{ parent() }}
   {{ encore_entry_script_tags('index') }}
   {{ encore_entry_script_tags('mypage') }}

{% endblock %} 

точек входа json

{
  "entrypoints": {
    "index": {
      "js": [
        "build/runtime.js",
        "build/index.js"
      ],
      "css": [
        "build/index.css"
      ]
    },
    "mypage": {
      "js": [
        "build/runtime.js",
        "build/mypage.js"
      ]
    }
  }
}

все приложение отображается нормально с тегом root из индекса, а «mypage» - нет.

это mypage. js

import React from "react";


export const MyPage = () => {

  return (<div id="mypage">My Page</div>);
};

webpack.config

ar Encore = require('@symfony/webpack-encore');

Encore
    // directory where compiled assets will be stored
    .setOutputPath('web/build/')
    // public path used by the web server to access the output path
    .setPublicPath('build/')
    // only needed for CDN's or sub-directory deploy
    //.setManifestKeyPrefix('build/')

    /*
     * ENTRY CONFIG
     *
     * Add 1 entry for each "page" of your app
     * (including one that's included on every page - e.g. "app")
     *
     * Each entry will result in one JavaScript file (e.g. app.js)      
     * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
     */


    .addEntry('index', './src/index.js')
    .addEntry('mypage', './src/app/pages/MyPage.js')
    //.addEntry('page1', './assets/js/page1.js')
    //.addEntry('page2', './assets/js/page2.js')

    // will require an extra script tag for runtime.js
    // but, you probably want this, unless you're building a single-page app
    .enableSingleRuntimeChunk()

    .cleanupOutputBeforeBuild()
    .enableSourceMaps(!Encore.isProduction())
    // enables hashed filenames (e.g. app.abc123.css)
    .enableVersioning(Encore.isProduction())

    // uncomment if you use TypeScript
    //.enableTypeScriptLoader()

    // uncomment if you use Sass/SCSS files
    .enableSassLoader()

    // uncomment if you're having problems with a jQuery plugin
    //.autoProvidejQuery()

    .enableReactPreset()
    .copyFiles({ from: './public' })
;

идентификатор правильно определен? Как я могу отобразить несколько записей?

мне действительно нужно осветить это

...