Skip to content

Commit

Permalink
fix: switch to mutation style for vite config mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Sep 29, 2022
1 parent 92d047c commit bd9a98f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-guests-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Switch to purely using the mutation style for update config in the config hook.
21 changes: 7 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
])
);

const optimizeExtensions = (optimizeDeps.extensions ??= []);
optimizeExtensions.push(".marko");

const esbuildOptions = (optimizeDeps.esbuildOptions ??= {});
const esbuildPlugins = (esbuildOptions.plugins ??= []);
esbuildPlugins.push(esbuildPlugin(compiler, baseConfig));

const ssr = (config.ssr ??= {});
if (ssr.noExternal !== true) {
ssr.noExternal = Array.from(
Expand All @@ -199,20 +206,6 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
)
);
}

return {
...config,
optimizeDeps: {
...config.optimizeDeps,
extensions: [".marko", ...(config.optimizeDeps?.extensions || [])],
esbuildOptions: {
plugins: [
esbuildPlugin(compiler, baseConfig),
...(config.optimizeDeps?.esbuildOptions?.plugins || []),
],
},
},
};
},
configureServer(_server) {
ssrConfig.hot = domConfig.hot = true;
Expand Down

0 comments on commit bd9a98f

Please sign in to comment.