Laravel Mix 4.0.7包含Vue

时间:2018-12-14 18:09:10

标签: reactjs laravel vue.js webpack laravel-mix

我刚刚将我们的应用程序升级到Laravel Mix 4.0.7,但现在看来它在Vue方面存在一些问题。

我正在运行没有Vue组件的Laravel / React应用程序,这是我在运行npm run watch-poll时遇到的问题。 Vue不在我的composer.json,package.json或任何JS文件中。

node_modules/webpack-cli/bin/cli.js:244
            throw err;
            ^

TypeError: Cannot read property 'find' of undefined

完整的回溯是:

at updateCssLoader.rule (node_modules/laravel-mix/src/components/Vue.js:39:26)
at Vue.updateCssLoader (node_modules/laravel-mix/src/components/Vue.js:87:21)
at Vue.updateCssLoaders (node_modules/laravel-mix/src/components/Vue.js:38:14)
at Vue.webpackConfig (node_modules/laravel-mix/src/components/Vue.js:28:14)
at JavaScript.webpackConfig (node_modules/laravel-mix/src/components/JavaScript.js:87:18)
at Mix.listen.config (node_modules/laravel-mix/src/components/ComponentFactory.js:74:54)
at events.(anonymous function).forEach.handler (node_modules/laravel-mix/src/Dispatcher.js:34:47)
at Array.forEach (<anonymous>)
at Dispatcher.fire (node_modules/laravel-mix/src/Dispatcher.js:34:28)
at Mix.dispatch (node_modules/laravel-mix/src/Mix.js:119:25)
at WebpackConfig.build (node_modules/laravel-mix/src/builder/WebpackConfig.js:28:13)
at Object.<anonymous> (node_modules/laravel-mix/setup/webpack.config.js:29:38)
at Module._compile (node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at WEBPACK_OPTIONS (node_modules/webpack-cli/bin/convert-argv.js:133:13)
at requireConfig (node_modules/webpack-cli/bin/convert-argv.js:135:6)
at node_modules/webpack-cli/bin/convert-argv.js:142:17
at Array.forEach (<anonymous>)
at module.exports (node_modules/webpack-cli/bin/convert-argv.js:140:15)
at yargs.parse (node_modules/webpack-cli/bin/cli.js:241:39)
at Object.parse (node_modules/yargs/yargs.js:567:18)
at node_modules/webpack-cli/bin/cli.js:219:8
at Object.<anonymous> (node_modules/webpack-cli/bin/cli.js:538:3)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (node_modules/webpack/bin/webpack.js:155:2)

webpack.config.js并没有什么特别之处,但在这里也是如此:

'use strict';

let mix                 = require('laravel-mix');
let ExtractTextPlugin   = require('extract-text-webpack-plugin');
let LiveReloadPlugin    = require('webpack-livereload-plugin');
let path                = require('path');

const backendExtract = new ExtractTextPlugin("css/backend/app.min.css");

mix.react('resources/assets/backend/js/app.js', 'public/backend/js')
    .js('resources/assets/frontend/js/app.js', 'public/js/app.js')
    .sass('resources/assets/frontend/sass/app.scss', 'css/frontend.min.css')
    .webpackConfig({
       module: {
         "rules": [
           {
             "test": /\.css$/,
             "loader": backendExtract.extract({
                     "fallback": "style-loader",
                     "use": "css-loader?modules=true&localIdentName=[name]__[local]--[hash:base64:6]&minimize=true"
             })
           }
       ]
       },
       "plugins": [
            backendExtract,
            new LiveReloadPlugin()
        ]
    });

我已经尝试研究Laravel混合源,但无法真正确定是什么原因导致它试图加载任何Vue组件。

0 个答案:

没有答案