ElMassimo / iles

🏝 The joyful site generator
https://iles.pages.dev
MIT License
1.08k stars 32 forks source link

Manual imports for unplugin-icons in client script are not being resolved #31

Closed drgarlic closed 3 years ago

drgarlic commented 3 years ago

Description πŸ“–

Basically the title. On build with vite-svg-loader it'll break and won't build but when importing icons only the build will finish but the icons won't show up. In dev mode there is no error but neither the sag imported nor the icons will show up.

Reproduction 🐞

Please provide a link to a repo that can reproduce the problem you ran into.

I'll try to do this ASAP

In the meantime here's the config file

import { defineConfig } from 'iles'
import path from 'path'

import svgLoader from 'vite-svg-loader'

export default defineConfig({
  modules: ['@islands/icons'],
  siteUrl: 'https://alfred.rndt.fr',
  vite: {
    resolve: {
      alias: {
        '/src': path.resolve(__dirname, 'src'),
      },
    },
    plugins: [svgLoader()],
  },
})
Dependencies Info _Run `npx iles info` and `pnpm list` (or `npm list`) and provide the output:_ ``` ```

Logs πŸ“œ

If not providing a reproduction:

Output _Run `DEBUG=iles:* npm run dev` or `DEBUG=iles:* npm run build` and provide the output:_ ``` ```

Screenshots πŸ“·

Provide console or browser screenshots of the problem.

Screenshots of the build mode:

With an svg:

image

With icons only:

image
ElMassimo commented 3 years ago

Hi Kevin, please don't open issues without providing the requested information, as it doesn't allow me to investigate why this might be happening.

Client scripts are completely detached from the component lifecycle, they are meant to run code in the browser and provide a convenient way to attach themselves to the prerendered HTML. You seem to be importing components on a client script, but that on its own wouldn't render them, and it wouldn't make them available in the template (use a standard or setup sfc script for that).

Keeping this open as a reminder to fail if aclient: script uses setup.


Unrelated, vite-svg-loader should not be necessary, you can place custom svgs in /icons and use them (IconAppLogo), or define a custom collection in unplugin-icons (passing config to the @islands/icons module).