From 6b3d4ed075475b752d10620d50897545ea836b65 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 2 Dec 2021 15:33:55 -0500 Subject: [PATCH] Some more progress on the new build --- examples/cool-app/src/pages/index.astro | 3 +++ examples/cool-app/src/styles/global.css | 3 +++ packages/astro/src/core/build/index.ts | 2 ++ .../astro/src/vite-plugin-build-css/index.ts | 1 + .../astro/src/vite-plugin-new-build/index.ts | 16 ++++++++++++++++ 5 files changed, 25 insertions(+) create mode 100644 examples/cool-app/src/styles/global.css create mode 100644 packages/astro/src/vite-plugin-new-build/index.ts diff --git a/examples/cool-app/src/pages/index.astro b/examples/cool-app/src/pages/index.astro index 255131362..c791ee29a 100644 --- a/examples/cool-app/src/pages/index.astro +++ b/examples/cool-app/src/pages/index.astro @@ -1,10 +1,13 @@ --- import imgUrl from '../images/penguin.jpg'; +import styleUrl from '../styles/global.css?url'; +debugger; --- Demo app +

Penguins are cool

diff --git a/examples/cool-app/src/styles/global.css b/examples/cool-app/src/styles/global.css new file mode 100644 index 000000000..4344ab4b3 --- /dev/null +++ b/examples/cool-app/src/styles/global.css @@ -0,0 +1,3 @@ +body { + background: lightcoral; +} \ No newline at end of file diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 1b4cdf055..e76cfcab2 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -5,6 +5,7 @@ import type { RenderedChunk } from 'rollup'; import { rollupPluginAstroBuildHTML } from '../../vite-plugin-build-html/index.js'; import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js'; +import { vitePluginNewBuild } from '../../vite-plugin-new-build/index.js'; import fs from 'fs'; import * as colors from 'kleur/colors'; import { performance } from 'perf_hooks'; @@ -186,6 +187,7 @@ class AstroBuilder { target: 'es2020', // must match an esbuild target }, plugins: [ + vitePluginNewBuild(), rollupPluginAstroBuildHTML({ astroConfig: this.config, astroPageStyleMap, diff --git a/packages/astro/src/vite-plugin-build-css/index.ts b/packages/astro/src/vite-plugin-build-css/index.ts index f26a36dce..95771bf39 100644 --- a/packages/astro/src/vite-plugin-build-css/index.ts +++ b/packages/astro/src/vite-plugin-build-css/index.ts @@ -145,6 +145,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin { // Delete CSS chunks so JS is not produced for them. generateBundle(opts, bundle) { + debugger; if (pureCSSChunks.size) { const pureChunkFilenames = new Set([...pureCSSChunks].map((chunk) => chunk.fileName)); const emptyChunkFiles = [...pureChunkFilenames] diff --git a/packages/astro/src/vite-plugin-new-build/index.ts b/packages/astro/src/vite-plugin-new-build/index.ts new file mode 100644 index 000000000..a9160afcb --- /dev/null +++ b/packages/astro/src/vite-plugin-new-build/index.ts @@ -0,0 +1,16 @@ +import type { Plugin as VitePlugin } from '../core/vite'; + +export function vitePluginNewBuild(): VitePlugin { + return { + name: '@astro/rollup-plugin-new-build', + + configResolved(resolvedConfig) { + // Delete this hook because it causes assets not to be built + const plugins = resolvedConfig.plugins as VitePlugin[]; + const viteAsset = plugins.find((p) => p.name === 'vite:asset'); + if(viteAsset) { + delete viteAsset.generateBundle; + } + } + } +} \ No newline at end of file