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

View File

@@ -32,7 +32,7 @@ jobs:
npm install
- name: "Build Aladin Lite"
run: |
npm run build
npm run build:prod
- name: "Publish Aladin Lite to npm"
run: |
npm publish

8
.gitignore vendored
View File

@@ -15,9 +15,11 @@ package-lock.json
src/core/Cargo.lock
src/core/target/
# this rust file is generated when compiling the code, so it is not
# useful to put it on git
src/core/src/shaders.rs
# the tmp glsl files used when minifying the shaders into the wasm (build.rs)
src/glsl/webgl2/**/*.min
src/glsl/webgl2/**/*.tmp
package/
## python related
# python environment

View File

@@ -11,7 +11,7 @@
let aladin;
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>

View File

@@ -30,7 +30,7 @@
"HiPS"
],
"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: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",
@@ -47,7 +47,8 @@
"test:playwright": "npx playwright test",
"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:dev": "npm run doc && open docs/index.html"
"doc:dev": "npm run doc && open docs/index.html",
"analyze": "vite build --mode analyze"
},
"devDependencies": {
"@playwright/test": "^1.47.0",

7903
src/core/src/shaders.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,66 +7,61 @@ import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
// For wasm generated by 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";
export default defineConfig({
build: {
minify: 'esbuild',
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/js/A.js'),
name: 'A',
formats: ["umd", "es"],
// the proper extensions will be added
fileName: 'aladin',
export default defineConfig(({mode}) => {
return {
build: {
minify: 'esbuild',
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/js/A.js'),
name: 'A',
formats: ["umd", "es"],
// 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: {},
//formats: ["es"],
target: ["es2015", "chrome58", "edge18", "firefox57", "node12", "safari11"],
//target: ["es2015"],
// Relative to the root
outDir: resolve(__dirname, 'dist'),
},
//publicDir: resolve(__dirname, 'src/img'),
plugins: [
wasm(),
wasmPack(resolve(__dirname, 'src/core')),
topLevelAwait(),
/*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')}
//publicDir: resolve(__dirname, 'src/img'),
plugins: [
wasm(),
wasmPack(resolve(__dirname, 'src/core')),
topLevelAwait(),
mode === 'analyze' &&
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
}),
],
},
//test: {
// globals: true,
// environment: 'happy-dom',
// include: [
// 'tests/unit/**/*.{test,spec}.{js,ts}'
// ],
// deps: {
// inline: ['core/pkg'],
// },
//},
server: {
open: '/examples/index.html',
},
resolve: {
alias: [
{find: '@', replacement: path.resolve(__dirname, '/src')},
{find: '#', replacement: path.resolve(__dirname, '/tests/unit')},
{find: '$', replacement: path.resolve(__dirname, '/tests/e2e')}
],
},
//test: {
// globals: true,
// environment: 'happy-dom',
// include: [
// 'tests/unit/**/*.{test,spec}.{js,ts}'
// ],
// deps: {
// inline: ['core/pkg'],
// },
//},
server: {
open: '/examples/index.html',
},
}
});