Vue 3 cli v4 - webpack - assets path

Viewed 31

I'm using Vue 3 cli version 4. I need help to configure my webpack.

My project will be on path for example /test, but I need to load my assets from path /vendor/test.

My fonts, scss are in folder /src/assets/fonts | /src/assets/scss

So I changed public path to /test and assetsDir to ../../vendor/test in vue.config.js.

For example I'm loading fonts with path "~@/assets/fonts/fa-light-300.woff2" but when I build my project, the resolved path is "vendor/test/fonts/fa-light-300.woff2".

Can you help me how can I configure webpack to resolve path to "/vendor/test/fonts/fa-light-300.woff2"

Here is my vue.config.js configuration

const { defineConfig } = require('@vue/cli-service');
const path = require("path");

module.exports = defineConfig({
    transpileDependencies: true,
    outputDir: path.resolve(__dirname, 'vendor/test'),
    publicPath: '/test',
    assetsDir: '../../vendor/test',
    filenameHashing: false,
    devServer: {
        devMiddleware: {
            writeToDisk: true
        }
    },
});
0 Answers
Related