Laravel Mix and Path Settings

A quick refernece for myself, when setting up new asp.net core spa and VueJS based project along with laravel mix the following setting helps in translating the path resolution correctly:

mix.setResourceRoot('/dist/')
   .setPublicPath(path.normalize('wwwroot/dist'));

so a typical laravel-mix webpack.mix.js file for asp.net core and vue js project (especially with admin-lte) would look like:

mix.js('client-src/main.js','')
    .extract([
        'vue',
        'vue-router',
        'vuex',
        'chart.js',
        'admin-lte',
        'bootstrap',
        'jquery',
    ])
    .autoload({
        jquery: ['$','jQuery', 'window.jQuery']
    })
    .sass('client-src/assets/vendor.scss','')
    .sass('client-src/assets/main.scss','')
    .setResourceRoot('/dist/')
    .setPublicPath(path.normalize('wwwroot/dist'))
comments powered by Disqus