attempt: externalize resolution with "pre"

This commit is contained in:
Nate Moore 2021-12-15 08:33:52 -06:00
parent a199bf3d2e
commit 9df3571d96
2 changed files with 22 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import { builtinModules, createRequire } from 'module';
import { fileURLToPath } from 'url';
import vite from './vite.js';
import astroVitePlugin from '../vite-plugin-astro/index.js';
import externalVitePlugin from '../vite-plugin-external/index.js';
import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
import markdownVitePlugin from '../vite-plugin-markdown/index.js';
@ -54,6 +55,7 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig,
exclude: [...ALWAYS_EXTERNAL],
},
plugins: [
externalVitePlugin({ config: astroConfig }),
configAliasVitePlugin({ config: astroConfig }),
astroVitePlugin({ config: astroConfig, devServer, logging }),
markdownVitePlugin({ config: astroConfig, devServer }),

View file

@ -0,0 +1,20 @@
import type vite from '../core/vite';
import type { AstroConfig } from '../@types/astro';
interface AstroPluginOptions {
config: AstroConfig;
}
/** Transform .astro files for Vite */
export default function astro({ config }: AstroPluginOptions): vite.Plugin {
return {
name: '@astrojs/vite-plugin-external',
enforce: 'pre',
resolveId(source, importer, options) {
if (source.includes('.config.')) {
console.log({ source, importer, options });
}
return null;
}
};
}