0

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>

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.