attempt: externalize resolution with "pre"
This commit is contained in:
parent
a199bf3d2e
commit
9df3571d96
2 changed files with 22 additions and 0 deletions
|
@ -6,6 +6,7 @@ import { builtinModules, createRequire } from 'module';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import vite from './vite.js';
|
import vite from './vite.js';
|
||||||
import astroVitePlugin from '../vite-plugin-astro/index.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 astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
|
||||||
import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
|
import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
|
||||||
import markdownVitePlugin from '../vite-plugin-markdown/index.js';
|
import markdownVitePlugin from '../vite-plugin-markdown/index.js';
|
||||||
|
@ -54,6 +55,7 @@ export async function createVite(inlineConfig: ViteConfigWithSSR, { astroConfig,
|
||||||
exclude: [...ALWAYS_EXTERNAL],
|
exclude: [...ALWAYS_EXTERNAL],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
externalVitePlugin({ config: astroConfig }),
|
||||||
configAliasVitePlugin({ config: astroConfig }),
|
configAliasVitePlugin({ config: astroConfig }),
|
||||||
astroVitePlugin({ config: astroConfig, devServer, logging }),
|
astroVitePlugin({ config: astroConfig, devServer, logging }),
|
||||||
markdownVitePlugin({ config: astroConfig, devServer }),
|
markdownVitePlugin({ config: astroConfig, devServer }),
|
||||||
|
|
20
packages/astro/src/vite-plugin-external/index.ts
Normal file
20
packages/astro/src/vite-plugin-external/index.ts
Normal 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue