add minified shaders

This commit is contained in:
Matthieu Baumann
2025-09-17 14:26:45 +02:00
parent 9bcc93877b
commit 547c5422d4
6 changed files with 7965 additions and 64 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ jobs:
npm install npm install
- name: "Build Aladin Lite" - name: "Build Aladin Lite"
run: | run: |
npm run build npm run build:prod
- name: "Publish Aladin Lite to npm" - name: "Publish Aladin Lite to npm"
run: | run: |
npm publish npm publish
+5 -3
View File
@@ -15,9 +15,11 @@ package-lock.json
src/core/Cargo.lock src/core/Cargo.lock
src/core/target/ src/core/target/
# this rust file is generated when compiling the code, so it is not # the tmp glsl files used when minifying the shaders into the wasm (build.rs)
# useful to put it on git src/glsl/webgl2/**/*.min
src/core/src/shaders.rs src/glsl/webgl2/**/*.tmp
package/
## python related ## python related
# python environment # python environment
+1 -1
View File
@@ -11,7 +11,7 @@
let aladin; let aladin;
A.init.then(() => { A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', {survey: "data/hips/CDS_P_DSS2_color", target: "05 40 59.12 -02 27 04.1", fov: 2, log: false}); aladin = A.aladin('#aladin-lite-div', {survey: "https://cds.unistra.fr/~boch/bug-al-om-change-relative-url/CDS_P_GALEXGR6_7_FUV", target: "05 40 59.12 -02 27 04.1", fov: 2, log: false});
}); });
</script> </script>
+3 -2
View File
@@ -30,7 +30,7 @@
"HiPS" "HiPS"
], ],
"scripts": { "scripts": {
"wasm:prod": "wasm-pack build ./src/core --target web --release --out-name core -- --features \"webgl2 minify_shaders\" && wasm-opt -Oz --strip-debug --strip-producers --dce -o src/core/pkg/core_bg.wasm src/core/pkg/core_bg.wasm", "wasm:prod": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2 && wasm-opt -Oz --strip-debug --strip-producers --dce -o src/core/pkg/core_bg.wasm src/core/pkg/core_bg.wasm",
"wasm:dev": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2", "wasm:dev": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2",
"wasm:dbg": "wasm-pack build --dev ./src/core --target web --out-name core -- --features=webgl2,dbg", "wasm:dbg": "wasm-pack build --dev ./src/core --target web --out-name core -- --features=webgl2,dbg",
"predeploy": "npm run build:prod && rm -rf aladin-lite*.tgz && npm pack", "predeploy": "npm run build:prod && rm -rf aladin-lite*.tgz && npm pack",
@@ -47,7 +47,8 @@
"test:playwright": "npx playwright test", "test:playwright": "npx playwright test",
"test:update-snapshots": "npx playwright test --update-snapshots", "test:update-snapshots": "npx playwright test --update-snapshots",
"doc": "jsdoc -c jsdoc.json src/js src/js/shapes src/js/libs/astro && cp aladin-logo.png docs/ && cp jsdoc-custom-style.css docs/ && cp jsdoc-make-responsive.js docs/", "doc": "jsdoc -c jsdoc.json src/js src/js/shapes src/js/libs/astro && cp aladin-logo.png docs/ && cp jsdoc-custom-style.css docs/ && cp jsdoc-make-responsive.js docs/",
"doc:dev": "npm run doc && open docs/index.html" "doc:dev": "npm run doc && open docs/index.html",
"analyze": "vite build --mode analyze"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.47.0", "@playwright/test": "^1.47.0",
File diff suppressed because it is too large Load Diff
+52 -57
View File
@@ -7,66 +7,61 @@ import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await"; import topLevelAwait from "vite-plugin-top-level-await";
// For wasm generated by wasm-pack // For wasm generated by wasm-pack
import wasmPack from 'vite-plugin-wasm-pack'; import wasmPack from 'vite-plugin-wasm-pack';
// To include and minify glsl into the bundle
//import glsl from 'vite-plugin-glsl';
// To include css into the bundle
//import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
//import fs from 'fs';
import { visualizer } from "rollup-plugin-visualizer"; import { visualizer } from "rollup-plugin-visualizer";
export default defineConfig({ export default defineConfig(({mode}) => {
build: { return {
minify: 'esbuild', build: {
lib: { minify: 'esbuild',
// Could also be a dictionary or array of multiple entry points lib: {
entry: resolve(__dirname, 'src/js/A.js'), // Could also be a dictionary or array of multiple entry points
name: 'A', entry: resolve(__dirname, 'src/js/A.js'),
formats: ["umd", "es"], name: 'A',
// the proper extensions will be added formats: ["umd", "es"],
fileName: 'aladin', // the proper extensions will be added
fileName: 'aladin',
},
rollupOptions: {},
//formats: ["es"],
target: ["es2015", "chrome58", "edge18", "firefox57", "node12", "safari11"],
//target: ["es2015"],
// Relative to the root
outDir: resolve(__dirname, 'dist'),
}, },
rollupOptions: {}, //publicDir: resolve(__dirname, 'src/img'),
//formats: ["es"], plugins: [
target: ["es2015", "chrome58", "edge18", "firefox57", "node12", "safari11"], wasm(),
//target: ["es2015"], wasmPack(resolve(__dirname, 'src/core')),
// Relative to the root topLevelAwait(),
outDir: resolve(__dirname, 'dist'), mode === 'analyze' &&
}, visualizer({
//publicDir: resolve(__dirname, 'src/img'), filename: 'stats.html', // output file
plugins: [ template: 'treemap', // "sunburst", "treemap", "network"
wasm(), gzipSize: true, // show gzip sizes
wasmPack(resolve(__dirname, 'src/core')), brotliSize: true, // show brotli sizes
topLevelAwait(), open: true // open stats.html automatically
/*glsl({ }),
minify: true
}),*/
/*visualizer({
filename: 'stats.html', // output file
template: 'treemap', // "sunburst", "treemap", "network"
gzipSize: true, // show gzip sizes
brotliSize: true, // show brotli sizes
open: true // open stats.html automatically
}),*/
],
resolve: {
alias: [
{find: '@', replacement: path.resolve(__dirname, '/src')},
{find: '#', replacement: path.resolve(__dirname, '/tests/unit')},
{find: '$', replacement: path.resolve(__dirname, '/tests/e2e')}
], ],
}, resolve: {
//test: { alias: [
// globals: true, {find: '@', replacement: path.resolve(__dirname, '/src')},
// environment: 'happy-dom', {find: '#', replacement: path.resolve(__dirname, '/tests/unit')},
// include: [ {find: '$', replacement: path.resolve(__dirname, '/tests/e2e')}
// 'tests/unit/**/*.{test,spec}.{js,ts}' ],
// ], },
// deps: { //test: {
// inline: ['core/pkg'], // globals: true,
// }, // environment: 'happy-dom',
//}, // include: [
server: { // 'tests/unit/**/*.{test,spec}.{js,ts}'
open: '/examples/index.html', // ],
}, // deps: {
// inline: ['core/pkg'],
// },
//},
server: {
open: '/examples/index.html',
},
}
}); });