Search code examples
symfonywebpackmaterializesymfony4

Webpack - Materialize with Symfony


I'm running a project on Symfony. I want to use for the first Time, Symfony 4, Webpack and Vagrant/Homestead.

My host is a Windows 10 My project is host on a VM made with vagrant/Homestead on Debian Wabpack (yarn) is installed

So,

I've made an "assets" folder inside I have a "css" folder, a "js" folder and a "scss" folder.

I've run the command

yarn add materialize-css

And then I run

yarn encore dev --watch

(ofc I've run yarn install previously)

But when I run my Symfony Website... Materialize is not detected.. My console show me the followings errors :

GET http://website.test/build/app.css/ net::ERR_ABORTED 404 (Not Found) (index):16

GET http://website.test/build/manifest.js net::ERR_ABORTED 404 (Not Found) favicon.ico:1

GET http://website.test/favicon.ico 404 (Not Found)

Here is My base template :

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>{% block title %}Welcome!{% endblock %}</title>
    {% block stylesheets %}
    <link rel="stylesheet" href={{ asset("build/app.css") }}/>
    {% endblock %}
</head>
<body>
<h1 class="grey">It works !</h1>
<a class="waves-effect waves-light btn">button</a>
<a class="waves-effect waves-light btn"><i class="material-icons left">cloud</i>button</a>
<a class="waves-effect waves-light btn"><i class="material-icons right">cloud</i>button</a>

{% block body %}{% endblock %}
    {% block javascripts %}
        <script src={{ asset("build/app.js") }}></script>
        <script src={{ asset("build/manifest.js") }}></script>
    {% endblock %}
</body>

I don't know what to do what can do my website working ?


Solution

  • If it's still not working you can try this:

    <script src={{ asset("./build/app.js") }}></script>
    <script src={{ asset("./build/runtime.js") }}></script>
    
    <script src={{ asset("./build/vendors~app.js") }}></script>
    //  for style
    <link rel="stylesheet" href={{ asset("./build/app.css") }}/>
    

    It worked for me.