1
1
100R2019-08-29 00:19:48
Laravel
100R, 2019-08-29 00:19:48

How to set up Laravel Mix to work with Vue?

There is router.js, in which each time you have to specify with your hands webpackChunkNomeso that the final file is saved in the folder I specified and has the same name as the source *.Vuefile. Is it possible to somehow transfer this process to webpack.mix.js, so as not to perform routine work?
router.js

import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

export default new Router({
    mode: 'history',
    routes: [
        {
            path: "/",
            component: () => import(/* webpackChunkName: "js/shop" */ "./views/Shop.vue")
        },
        {
            path: "/cart",
            component: () => import(/* webpackChunkName: "js/cart" */ "./views/Cart.vue")
        }
    ]
});

When importing scssa file directly in the component, publica folder is created vendors~jsin it, and in it the *.jsfiles responsible for displaying styles ( css-loader). How can I rename this folder and move it to a folder js?
<template>
    <div></div>
</template>

<script>
    export default {
        //
    }
</script>

<style lang="scss">
    @import "app.scss";
</style>

5d66ef6d569db625769162.png
webpack.mix.js
const mix = require('laravel-mix');

mix.webpackConfig({
    resolve: {
        alias: {
            "@": path.resolve(__dirname, 'resources/js')
        }
    }
});

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question