Setting up vue and laravel trouble

2019-09-14 16:13发布

问题:

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]);