I have a Laravel application that uses webpack to compile some SASS assets.
mix.js('resources/js/vue/User/dashboard.js', 'public/js/User')
.js('resources/js/vue/home.js', 'public/js')
.js('resources/js/vue/admin-dashboard.js', 'public/js/admin')
.sass('resources/sass/app.scss', 'public/css')
.sass('resources/sass/layouts.scss', 'public/css');
Inside one of the JS files it compiles, is a Vue-Router instance that creates webpack chunks:
const router = new VueRouter({
mode: "history",
routes: [
{
path: "/admin",
component: () => import("./admin/Dashboard.vue" /* webpackChunkName: "js/admin/components/dashboard" */ )
}
],
scrollBehavior (to, from, savedPosition) {
return savedPosition || { x: 0, y: 0 };
}
});
The above code breaks the compiling of my CSS assets. When I run npm run dev, the output says that the CSS files are generated properly.
DONE Compiled successfully in 3177ms 3:16:42 PM
Asset Size Chunks Chunk Names
/css/app.css 196 KiB mix [emitted] mix
/css/layouts.css 9.91 KiB mix [emitted] mix
However when I check the .css files, both of them are empty. If I comment out the Vue-Router portion, the CSS files generate correctly.
Why does including the Vue-Router webpack chunks break the compiling of the CSS assets?
