hooking up the last build steps to copy over .wasm files

This commit is contained in:
Tony Sullivan 2022-09-12 16:19:25 -05:00
parent 48121b0fae
commit b00776c02f
4 changed files with 63 additions and 5 deletions

View file

@ -37,6 +37,7 @@
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"postbuild": "astro-scripts copy \"src/**/*.wasm\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "mocha --exit --timeout 20000 test"
},
@ -52,6 +53,7 @@
"@types/sharp": "^0.30.5",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"kleur": "^4.1.4"
"kleur": "^4.1.4",
"rollup-plugin-copy": "^3.4.0"
}
}

View file

@ -1,4 +1,4 @@
import type { AstroConfig, AstroIntegration } from 'astro';
import type { AstroConfig, AstroIntegration, BuildConfig } from 'astro';
import { ssgBuild } from './build/ssg.js';
import type { ImageService, TransformOptions } from './loaders/index.js';
import type { LoggerLevel } from './utils/logger.js';
@ -38,6 +38,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
};
let _config: AstroConfig;
let _buildConfig: BuildConfig;
// During SSG builds, this is used to track all transformed images required.
const staticImages = new Map<string, Map<string, TransformOptions>>();
@ -73,6 +74,9 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
});
}
},
'astro:build:start': ({ buildConfig }) => {
_buildConfig = buildConfig
},
'astro:build:setup': () => {
// Used to cache all images rendered to HTML
// Added to globalThis to share the same map in Node and Vite
@ -102,7 +106,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
: {};
},
'astro:build:done': async ({ dir }) => {
await copyLibFiles(dir);
await copyLibFiles(_config.output === 'static' ? dir : _buildConfig.server);
if (_config.output === 'static') {
// for SSG builds, build all requested image transforms to dist

View file

@ -1,8 +1,11 @@
import { defineConfig } from 'astro/config';
import image from '@astrojs/image';
import node from '@astrojs/node';
// https://astro.build/config
export default defineConfig({
site: 'http://localhost:3000',
integrations: [image({ logLevel: 'silent' })]
integrations: [image({ logLevel: 'silent' })],
output: 'server',
adapter: node()
});

View file

@ -2227,6 +2227,7 @@ importers:
kleur: ^4.1.4
magic-string: ^0.25.9
mime: ^3.0.0
rollup-plugin-copy: ^3.4.0
sharp: ^0.30.6
dependencies:
'@altano/tiny-async-pool': 1.0.2
@ -2240,6 +2241,7 @@ importers:
astro: link:../../astro
astro-scripts: link:../../../scripts
kleur: 4.1.5
rollup-plugin-copy: 3.4.0
packages/integrations/image/test/fixtures/background-color-image:
specifiers:
@ -8941,10 +8943,23 @@ packages:
resolution: {integrity: sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==}
dev: true
/@types/fs-extra/8.1.2:
resolution: {integrity: sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==}
dependencies:
'@types/node': 18.7.16
dev: true
/@types/github-slugger/1.3.0:
resolution: {integrity: sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==}
dev: true
/@types/glob/7.2.0:
resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==}
dependencies:
'@types/minimatch': 5.1.2
'@types/node': 18.7.16
dev: true
/@types/glob/8.0.0:
resolution: {integrity: sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==}
dependencies:
@ -10341,6 +10356,10 @@ packages:
color-string: 1.9.1
dev: false
/colorette/1.4.0:
resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==}
dev: true
/colorette/2.0.19:
resolution: {integrity: sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==}
dev: false
@ -10373,7 +10392,7 @@ packages:
dev: false
/concat-map/0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
/concurrently/7.4.0:
resolution: {integrity: sha512-M6AfrueDt/GEna/Vg9BqQ+93yuvzkSKmoTixnwEJkH0LlcGrRC2eCmjeG1tLLHIYfpYJABokqSGyMcXjm96AFA==}
@ -12228,6 +12247,20 @@ packages:
/globalyzer/0.1.0:
resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==}
/globby/10.0.1:
resolution: {integrity: sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==}
engines: {node: '>=8'}
dependencies:
'@types/glob': 7.2.0
array-union: 2.1.0
dir-glob: 3.0.1
fast-glob: 3.2.12
glob: 7.2.3
ignore: 5.2.0
merge2: 1.4.1
slash: 3.0.0
dev: true
/globby/11.1.0:
resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==}
engines: {node: '>=10'}
@ -12863,6 +12896,11 @@ packages:
resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}
engines: {node: '>=12'}
/is-plain-object/3.0.1:
resolution: {integrity: sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==}
engines: {node: '>=0.10.0'}
dev: true
/is-plain-object/5.0.0:
resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==}
engines: {node: '>=0.10.0'}
@ -15784,6 +15822,17 @@ packages:
dependencies:
glob: 7.2.3
/rollup-plugin-copy/3.4.0:
resolution: {integrity: sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==}
engines: {node: '>=8.3'}
dependencies:
'@types/fs-extra': 8.1.2
colorette: 1.4.0
fs-extra: 8.1.0
globby: 10.0.1
is-plain-object: 3.0.1
dev: true
/rollup-plugin-inject/3.0.2:
resolution: {integrity: sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==}
deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.