Skip to content

Commit

Permalink
Update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpapercut committed May 3, 2024
1 parent cb5f70c commit 2a3b0c4
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
import esbuild from 'esbuild';
import fs from 'fs';

const entryPoint = './wypst.js';
const isDevelopment = process.env.NODE_ENV === 'development';

// Inline wasm build
esbuild.build({
entryPoints: ['./wypst.js'],
entryPoints: [entryPoint],
bundle: true,
minify: true,
sourcemap: true,
minify: !isDevelopment,
sourcemap: isDevelopment,
target: ['es6'],
outfile: './dist/wypst_inlined.js',
outfile: './dist/wypst.min.js',
format: 'iife',
globalName: 'wypst',
loader: {
'.wasm': 'binary'
},
});

// Normal build
esbuild.build({
entryPoints: [entryPoint],
bundle: true,
minify: !isDevelopment,
sourcemap: isDevelopment,
target: ['es6'],
outfile: './dist/wypst.js',
format: 'iife',
globalName: 'wypst',
loader: {
'.wasm': 'file'
},
metafile: true,
assetNames: 'wypst',
});

// Copy CSS files
fs.copyFileSync('node_modules/katex/dist/katex.css', 'dist/wypst.css');
fs.copyFileSync('node_modules/katex/dist/katex.min.css', 'dist/wypst.min.css');

0 comments on commit 2a3b0c4

Please sign in to comment.