1

I'm using Pug for the first time with Vite and the plugin @vituum/vite-plugin-pug.
Here's the structure of my project:

src
  js
  css

static
  imgs
    image.jpg

views
  pages
    index.pug

I'd like to call my image in my index.pug file with this path : /imgs/image.jpg without the ../static/ before. I tried to change the resolvers and other stuff but no success.

img(src="/imgs/image.jpg")

Here's my vite.config.jsfile:

import vituum from 'vituum'
import { fileURLToPath, URL } from 'node:url'
import pug from '@vituum/vite-plugin-pug'
import pages from 'vituum/plugins/pages.js'
import imports from 'vituum/plugins/imports.js'

export default {
    base: './',
    publicDir: '../static/',
    plugins: [
        vituum(),
        pug(),
        imports({
            paths: [
                '/src/styles/*/**', 
                '/src/scripts/*/**', 
                '/src/assets/*/**'
            ]
        }),
        pages({
            dir: './views/pages',
            root: './',
            normalizeBasePath: true
        })
    ],
}

Perhaps I should make another structure? Can someone help me, please? (That's my first project using Vite)

All best, Lucie

0

Browse other questions tagged or ask your own question.