Search code examples
phplaravelhomesteadmetronic

Metronic Laravel Integration


I am trying to integrate the metronic theme into my existing laravel project. I work in Laravel homestead structure.

I did the steps in the "https://keenthemes.com/metronic/?page=docs&section=laravel-integration" link one by one and I didn't get any errors. However, the /laravel/public/js/app.js and /laravel/public/js/app.css files that did not occur as mentioned in step 6 did not occur. What could be the reason for this?

My webpack.mix.js file content:

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/call.js', 'public/js');
mix.js('resources/js/echo.js', 'public/js');

// copy images folder into laravel public folder
mix.copyDirectory('resources/demo1/src/assets/media', 'public/assets/media');

/**
* plugins specific issue workaround for webpack
* @see https://github.com/morrisjs/morris.js/issues/697
* @see https://stackoverflow.com/questions/33998262/jquery-ui-and-webpack-how-to-manage-it-into-module
*/
mix.webpackConfig({
   resolve: {
       alias: {
           'morris.js': 'morris.js/morris.js',
           'jquery-ui': 'jquery-ui',
       },
   },
});

Solution

  • You forgot to compile the sass and js files mentioned in step 4.

    Add the following to your webpack.mix.js:

    mix.js('resources/js/app.js', 'public/js')
        .sass('resources/sass/app.scss', 'public/css');
    

    To fix the issue with bootstrap you have to make sure the import path is correct:

    Change the following in resources/demo1/src/assets/sass/style.scss:

    import 'bootstrap/scss/bootstrap';
    

    to

    import '~bootstrap/scss/bootstrap';