Some more progress on the new build
This commit is contained in:
parent
8f67687eef
commit
6b3d4ed075
5 changed files with 25 additions and 0 deletions
|
@ -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>
|
||||||
|
|
3
examples/cool-app/src/styles/global.css
Normal file
3
examples/cool-app/src/styles/global.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
body {
|
||||||
|
background: lightcoral;
|
||||||
|
}
|
|
@ -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,
|
||||||
|
|
|
@ -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]
|
||||||
|
|
16
packages/astro/src/vite-plugin-new-build/index.ts
Normal file
16
packages/astro/src/vite-plugin-new-build/index.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue