sveltejs / svelte-loader

Webpack loader for svelte components.
MIT License
597 stars 72 forks source link

Add generate option to allow for SSR compilation from webpack. #145

Closed arackaf closed 3 years ago

arackaf commented 3 years ago

Right now it doesn't appear as though you can build a Svelte component with webpack that's fit for SSR. One big reason you might want to do that is to take advantage of webpack path resolution, ie

resolve: {
  extensions: [".mjs", ".ts", ".tsx", ".js", ".svelte"],
  modules: [path.resolve("./"), path.resolve("./node_modules")],

which allows you to import things from, say,

import { foo } from "app/a/b/c/d/foo.js" 

rather than

import { foo } from "../../../d/foo.js"

This PR exposes the "generate" compile option to the plugin, for this purpose.

arackaf commented 3 years ago

So sorry for the churn. I missed that this prop is already passed through, here

https://github.com/sveltejs/svelte-loader/blob/d4e2c2025e8cf0cf448d61a5f5206d6e77ee0d9a/index.js#L132