question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with Laravel Mix when using async vue component

See original GitHub issue

Description:

Laravel-Mix version : 5

My webpack.mix.js file:

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


mix.js('resources/assets/js/app.js', 'assets/js')
    .sass('resources/assets/sass/app.scss', 'assets/css')
    .sass('resources/assets/sass/vendor.scss', 'assets/css')
    .copy('resources/assets/images', 'assets/images')
    .options({
        processCssUrls: false,
        postCss: [tailwindcss('./tailwind.config.js')],
    })
    .extract()
    .purgeCss()
    .browserSync('http://localhost:8080');

I created some Vue component and tried to include them as async:

import Vue from 'vue'
import App from './App.vue'
import Router from 'vue-router'

const Dashboard = () => import(/* webpackChunkName: "./assets/js/dashboard" */ './components/Dashboard')
const DashboardHome = () => import(/* webpackChunkName: "./assets/js/dashboard" */ './pages/Home')

import store from './store'


Vue.config.productionTip = false

Vue.use(Router)

const routes = [
  { path: '/', redirect: { name: 'DashboardHome' } },
  { path: '/dashboard', component: Dashboard, children: [
      { path: '/', redirect: { name: 'DashboardHome' } },
      { path: 'home', name: 'DashboardHome', component: DashboardHome }
    ]
  }
]

const router = new Router({
  mode: 'hash',
  routes
})

new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')

The files (js/css) are created but css files contains JS Code when running yarn run prod

https://www.dropbox.com/s/osakt96rgl83sx0/Screenshot 2020-06-08 22.28.51.png?dl=0

https://www.dropbox.com/s/iw744tfq30xt1v2/Screenshot 2020-06-08 22.29.19.png?dl=0

How can I fix this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
denjalandcommented, Jun 16, 2020

@itsursujit thanks for your feedback - much appreciated - I’ll dig into it again a bit later again.

1reaction
sujit-baniyacommented, Jun 16, 2020

All seems fine to me.

my code now is:

const mix = require('laravel-mix');
require('laravel-mix-purgecss');
const tailwindcss = require('tailwindcss');
// ...
mix.js('resources/assets/js/app.js', 'assets/js')
    .sass('resources/assets/sass/app.scss', 'assets/css')
    .sass('resources/assets/sass/vendor.scss', 'assets/css')
    .copy('resources/assets/images', 'assets/images')
    .options({
        processCssUrls: false,
        postCss: [tailwindcss('./tailwind.config.js')],
    })
    .purgeCss()
    .browserSync('http://localhost:8080');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with Laravel Mix when using async vue component
Description: Laravel-Mix version : 5 My webpack.mix.js file: const mix = require('laravel-mix'); require('laravel-mix-purgecss'); ...
Read more >
Problem with Laravel Mix when using async vue ... - Laracasts
Problem with Laravel Mix when using async vue component. Laravel-Mix version : 5. My webpack.mix.js file: Copy Code const mix = require('laravel-mix'); ...
Read more >
Laravel 8 Mix npm run development error with vue.js
I've laravel Vue js project. I need to make changes to our project but when I try to use npm run development to...
Read more >
Asset Bundling (Vite) - The PHP Framework For Web Artisans
However, it lacks some features that Laravel Mix supports, such as the ability to copy arbitrary assets into the build that are not...
Read more >
Another issue with laravel-mix and async components - Reddit
Like I said last night, Mix 4.0 has tons of problems with async/dynamic imports. This isn't a problem with Mix, but rather the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found