Search code examples
laravelvue.jslaravel-storage

How to import JSON from Storage Folder in VUE using Laravel?


I'm looking for a much cleaner way than this:

<script>
   import list from '../../../../../../../storage/app/public/json/listofcuisines_en.json';
   export default {}
</script>

How?


Solution

  • You can use webpack resolve in webpack.mix.js

    mix.webpackConfig({
        resolve: {
           alias: {
               "@": path.resolve(
                   __dirname,
                   "your_path_to_source_folder"
               )
           }
        }
    });
    

    and then in component

    <script>
       import list from '@/storage/app/public/json/listofcuisines_en.json';
       export default {}
    </script>