Setting up vue and laravel trouble

懵懂的女人 提交于 2019-12-25 12:07:28

问题


Here is my gulpfile.js file

var elixir = require('laravel-elixir');
require('laravel-elixir-webpack');

elixir(function(mix) {

   mix.styles([
      'vendor.css',
      'font-awesome.css',
      'theme-default.css',
      'custom.css'
      ],'public/assets/css/index.css');

     mix.scripts([
      'vendor.js',
      'demodata.js',
      'app.js',
      'demo.js'
      ],'public/assets/js/index.js');

   mix.webpack('main.js');
   mix.version('js/main.js','assets/css/index.css','assets/js/index.js');

});

And here is my master.blade.php

<!DOCTYPE html>
<html lang= "en">
<head>
    <meta charset = "utf-8">
    <title>Wiredcademy | @yield('title')</title>
     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0, shrink-to-fit=no">
     <meta name="format-detection" content="telephone=no">
     <link href="http://fonts.googleapis.com/css?family=Montserrat:400,700%7cSource+Sans+Pro:200,400,600,700,900,400italic,700italic&amp;subset=latin,latin-ext" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="{{ elixir('assets/css/index.css') }}">
</head>
    <body class="index menu-default hover-default scroll-animation">    

    @yield('contents')

    <script src="{{ elixir('assets/js/index.js') }}"></script>
    <script src="{{ elixir('js/main.js') }}"></script>
</body>
</html>

I'm fairly new to using gulp. So I did type gulp and gulp watch commands to keep track of scripts and stylesheets and changes to my main.js respectively But when I deploy the app through php artisan serve.

it says:

File assets/css/index.css not defined in asset manifest. (View: A:\xampp\htdocs\restate\resources\views\layouts\master.blade.php) (View: A:\xampp\htdocs\restate\resources\views\layouts\master.blade.php)


回答1:


Perhaps due to your versionning. When you use mix.version(), you will have to use mix to pull your assets as well in your layout file, because mix hashes the file name and only it knows what the current name is.

<link rel="stylesheet" href="{{ mix('/assets/css/index.css') }}">

Don't forget the wordware lash /.

Source here: https://laravel.com/docs/5.4/mix#versioning-and-cache-busting

Update Using Laravel 2, sorry.

I think the error comes from your use of mix.version() still. You pass it many strings instead of an array.

mix.version('single-file');
mix.version(['file-1', 'file-2]);


来源:https://stackoverflow.com/questions/42709842/setting-up-vue-and-laravel-trouble

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!