jcord's avatar
Level 4

Custom webpack config not working after upgrading mix from v4 to v6

I inherited a project which uses mix along with the webpackConfig option. All worked fine on v4 but when i upgrade to v6 when compiling i get errors saying it cannot find my modules.

Here is the webpack config i have

.webpackConfig({
        resolve: {
            alias: {
                EntryPoints: path.resolve(__dirname, 'resources/js'),
                Libraries: path.resolve(__dirname, 'resources/js/lib'),
                Components: path.resolve(__dirname, 'resources/js/components'),
                Mixins: path.resolve(__dirname, 'resources/js/mixins'),
                Stores: path.resolve(__dirname, 'resources/js/stores')
            }
        },
        entry: entryPoints,
        module: {
            rules: [
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    use: ['babel-loader']
                },
            ]
        },
        plugins: [
            new CleanWebpackPlugin([
                path.resolve(__dirname, 'public/css/**/*.css'),
                path.resolve(__dirname, 'public/js/**/*.js')
            ])
        ],
        optimization: {
            runtimeChunk: "single", 
            splitChunks: {
                cacheGroups: {
                    commons: {
                        name: 'js/commons',
                        chunks: 'initial',
                        minChunks: 4
                    }
                }
            }
        }
    })

The errors i get look like the below (this is just a snippet as there are lots the same)

ERROR in ./resources/js/batchTable.js 1:0-59 Module not found: Error: Can't resolve '/Components/BatchTable/BatchTable' in '/home/jamie/Code/e3g-erp/resources/js'

and this file looks like

import BatchTable from 'Components/BatchTable/BatchTable';
import store from 'Stores/BatchTable';
import 'EntryPoints/transferBatch';

window.Vue.component('BatchTable', BatchTable);
window.VuexStoreModules.set('batchTable', store);

I have tried using full paths for files and not the aliases but to no avail, therefore i think it has to be the loader but looking at docs not sure where it is going wrong

Any ideas would be great.

0 likes
2 replies

Please or to participate in this conversation.