reepolee / svelte-routify-windi-vite

Svelte Starter template with Routify file-based router, WindiCSS Tailwind compiler and Vite
52 stars 10 forks source link

[feature] SSG export #6

Closed ImmanuelSamuel closed 3 years ago

ImmanuelSamuel commented 3 years ago

Could you add SSG export for routify? I tried it but have issues with the modules not loading correctly (searches for modules in node_modules instead of dist/assets).

alesvaupotic commented 3 years ago

I'll ask @jakobrosenberg for some help on this one, Routify is his project and using https://github.com/roxiness/spank for SSG. Do mind this is an experimental project on integrating bleeding edge ViteJS and WindiCSS.

jakobrosenberg commented 3 years ago

What does Vite's build output structure look like?

alesvaupotic commented 3 years ago

image

jakobrosenberg commented 3 years ago

Thanks. Seeing as the script has a hash, the spank config has to be a separate .js file.

This might work:

// spank.config.js
module.exports = {
  entrypoint: "index.html",
  outputDir: "dist",
  inlineDynamicImports: true,
  script: require('fs')
    .readFileSync('./index.html', 'utf8')
    .match(/<script .+?src="\/([^"]+)"/)[1]
}
ImmanuelSamuel commented 3 years ago

yeah I had made those changes but the other imports do not work i.e., it looks for _layout.js in node_modules folder. @alesvaupotic do you have the same issue as well or is it only on my end.

alesvaupotic commented 3 years ago

Same issue, yes. Stand by for updates.

jakobrosenberg commented 3 years ago

https://github.com/roxiness/spank/releases/tag/v1.6.0

No spank.config.js required.

vite.config.js needs to be updated:

  build: {
    polyfillDynamicImport: false,
    cssCodeSplit: false,
    ...
  },
  resolve: {
    dedupe: ['@roxi/routify'],
    ...

Fingers crossed. 🤞