I want to use an alias in my project, but when I build the project, the alias does not change.
@public it stays that way

vite.config.js

export default defineConfig({
resolve: {
    alias: {
        '@public': path.resolve(__dirname, 'public'),
    },
},
server: {
    open: '/pages/index.html'
},
preview: {
    port: 1234,
},
build: {
    rollupOptions: {
        input: {
            main: resolve(__dirname, 'pages/index.html'),
        },
    },
},
plugins: [
    handlebars({
        partialDirectory: [
            resolve(__dirname, 'src/html/blocks/'),
            resolve(__dirname, 'src/html/'),
            resolve(__dirname, 'src/html/support')
        ],
    }),
],

})

build index.html have @public

<img src="@public/images/logo.png">

I wanted to replace ../../../public in my project with an alias, but it didn’t work out

New contributor

Denis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1