AlixL
AlixL

Reputation: 372

Integrating Angular 2 with Symfony 3

I am trying to integrate Angular 2 with Symfony 3. I used npm to install node modules, however I can't link them from my view base base.html.twig. Indeed, every script I add doesn't work (not even in the source code of the page).

The following scripts are required, how can I add them ?

<!-- IE required polyfills, in this exact order -->
<script src="../../node_modules/es6-shim/es6-shim.min.js"></script>
<script src="../../node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="../../node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>

<script src="../../node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="../../node_modules/systemjs/dist/system.src.js"></script>
<script src="../../node_modules/rxjs/bundles/Rx.js"></script>
<script src="../../node_modules/angular2/bundles/angular2.dev.js"></script>
<script>
      System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });
      System.import('../components/main')
            .then(null, console.error.bind(console));
</script>

Upvotes: 0

Views: 1033

Answers (1)

zeykzso
zeykzso

Reputation: 493

In symfony, the root folder of the website should be the web folder, everything that is outside of this should be forbidden to be accessed, so I would say this is a normal behaviour. I suggest to copy all these scripts from node_modules to web/scripts for example - manually, or even better, using gulp or other js tools.

Upvotes: 4

Related Questions