Some more progress on the new build

This commit is contained in:
Matthew Phillips 2021-12-02 15:33:55 -05:00
parent 8f67687eef
commit 6b3d4ed075
5 changed files with 25 additions and 0 deletions

View file

@ -1,10 +1,13 @@
--- ---
import imgUrl from '../images/penguin.jpg'; import imgUrl from '../images/penguin.jpg';
import styleUrl from '../styles/global.css?url';
debugger;
--- ---
<html> <html>
<head> <head>
<title>Demo app</title> <title>Demo app</title>
<link rel="stylesheet" href={styleUrl}>
</head> </head>
<body> <body>
<h1>Penguins are cool</h1> <h1>Penguins are cool</h1>

View file

@ -0,0 +1,3 @@
body {
background: lightcoral;
}

View file

@ -5,6 +5,7 @@ import type { RenderedChunk } from 'rollup';
import { rollupPluginAstroBuildHTML } from '../../vite-plugin-build-html/index.js'; import { rollupPluginAstroBuildHTML } from '../../vite-plugin-build-html/index.js';
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/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 fs from 'fs';
import * as colors from 'kleur/colors'; import * as colors from 'kleur/colors';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
@ -186,6 +187,7 @@ class AstroBuilder {
target: 'es2020', // must match an esbuild target target: 'es2020', // must match an esbuild target
}, },
plugins: [ plugins: [
vitePluginNewBuild(),
rollupPluginAstroBuildHTML({ rollupPluginAstroBuildHTML({
astroConfig: this.config, astroConfig: this.config,
astroPageStyleMap, astroPageStyleMap,

View file

@ -145,6 +145,7 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin {
// Delete CSS chunks so JS is not produced for them. // Delete CSS chunks so JS is not produced for them.
generateBundle(opts, bundle) { generateBundle(opts, bundle) {
debugger;
if (pureCSSChunks.size) { if (pureCSSChunks.size) {
const pureChunkFilenames = new Set([...pureCSSChunks].map((chunk) => chunk.fileName)); const pureChunkFilenames = new Set([...pureCSSChunks].map((chunk) => chunk.fileName));
const emptyChunkFiles = [...pureChunkFilenames] const emptyChunkFiles = [...pureChunkFilenames]

View file

@ -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;
}
}
}
}