-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuse.js
More file actions
30 lines (28 loc) · 824 Bytes
/
fuse.js
File metadata and controls
30 lines (28 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const stylus = require('stylus');
const stylusPlugin = {
name: 'stylus',
setup(build) {
build.onLoad({ filter: /\.styl$/ }, async (args) => {
const source = await fs.promises.readFile(args.path, 'utf8');
const css = await new Promise((resolve, reject) => {
stylus(source)
.set('filename', args.path)
.set('compress', true)
.render((err, css) => err ? reject(err) : resolve(css));
});
return { contents: css, loader: 'css' };
});
},
};
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'public/index.js',
sourcemap: true,
target: ['es2015'],
platform: 'browser',
plugins: [stylusPlugin],
}).catch(() => process.exit(1));