sr57's avatar
Level 39

.vue() in webpack.mix.js?

HI all,

I have a Vue.js component that works in a Laravel8 project.

To compile, I have to add .vue() in my webpack.mix.js

I don't remember where I found this 'trick', I see nothing in the Laravel doc that says that 'No further configuration is required:'

https://laravel.com/docs/8.x/mix#vue

Does sb has an explanation?

Thanks in advance.

0 likes
8 replies
piljac1's avatar

I've used Vue a lot in my Laravel projects and never in my life I had to use .vue() in Mix. Always used .js(). What's the issue you're encountering with .js()?

sr57's avatar
Level 39

Hi @piljac1 , thanks for your answer.

I'm really not comfortable with webpack & mix.

My webpack.mix.js that works

const mix = require('laravel-mix');


mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css', [
        require('postcss-import'),
        require('tailwindcss'),
    ])
    .webpackConfig(require('./webpack.config'))
    .vue();

If I remove .vue() I got this error :

 error  in ./resources/js/components/ExVue3Component.vue

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
|     <div>I'm a Vue3.js component.</div>
|     {{ msg1 }}

If I replace .vue() by js() I got this error :

webpack-cli] AssertionError [ERR_ASSERTION]: mix.js() is missing required parameter 1: entry

sr57's avatar
Level 39

Thanks @sergiu17

With a very quick reading, I see nothing about the cde 'vue()'

I have to read it deeper ... to be continued

Sergiu17's avatar

How ./webpack.config looks like? could you share it please?

sr57's avatar
Level 39

@sergiu17

cat webpack.config.js

const path = require('path');

module.exports = {
    resolve: {
        alias: {
            '@': path.resolve('resources/js'),
        },
    },
};
Dwight's avatar
Dwight
Best Answer
Level 7

Check which version of Laravel Mix you have installed, and which docs you're referencing. The latest version 6.0 introduced the new vue() method and you can see the documentation for this new version here. The new Laravel app scaffold and docs still reference the previous version 5.0 for the time being.

2 likes

Please or to participate in this conversation.