Search code examples
laravelnpmvue.jsmasonry

laramix with vue-masonry package error


I'm wroking on laravel 5.4 project.
The question is vue-masonry(https://github.com/shershen08/vue-masonry) package doesn't work with the following error

[Vue warn]: Failed to resolve directive: masonry
[Vue warn]: Failed to resolve directive: masonry-tile

Please help me to check my setting that are the wrong part.

Here is my app.js :

require('./bootstrap');

require('masonry-layout');
require('imagesloaded');
require('fancybox');

var vueMasonry = require('vue-masonry');
Vue.use(vueMasonry);

the bootstrap.js still original without modify a word, and package.json is here:

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "laravel-mix": "0.*",
    "lodash": "^4.17.4",
    "minifier": "^0.8.1",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1"
  },
  "dependencies": {
    "axios": "^0.15.3",
    "fancybox": "^3.0.0",
    "imagesloaded": "^4.1.3",
    "jquery": "^3.1.1",
    "masonry-layout": "^4.2.0",
    "swiper": "^3.4.2",
    "vue": "^2.1.10",
    "vue-masonry": "^0.10.7"
  }
}

And the final Html is something like:

<div class="grid-wrap"
     v-masonry 
     fit-width="true"
     transition-duration="0.3s"
     item-selector=".grid-item"
     fit-width="true"
>
    <div v-masonry-tile class="grid-item" v-for="wall in walls">
        <div class="grid-date">
            @{{ wall.created_at }}
        </div> 
    </div>
</div>

Solution

  • The package itself seems to be broken according to this issue

    https://github.com/shershen08/vue-masonry/issues/26

    Just scroll down and you'll find someone with the same issue as you and the latest answer was only 13 hours ago so i doubt it's been fixed yet.