-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
40 lines (37 loc) · 1.2 KB
/
build.mjs
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
31
32
33
34
35
36
37
38
39
40
import * as esbuild from 'esbuild';
import { sassPlugin } from 'esbuild-sass-plugin';
import postcss from 'postcss';
import autoprefixer from 'autoprefixer';
import fs from 'node:fs';
// import eslint from 'esbuild-plugin-eslint';
import browserslist from 'browserslist';
import {
esbuildPluginBrowserslist,
resolveToEsbuildTarget,
} from 'esbuild-plugin-browserslist';
let result = await esbuild.build({
entryPoints: [
{ out: 'index', in: 'index.js'},
],
bundle: true,
minify: true,
sourcemap: true,
metafile: true,
format: 'esm',
splitting: true,
globalName: 'electoralareas',
outdir: 'static',
plugins: [
sassPlugin({
async transform(source) {
const { css } = await postcss([autoprefixer]).process(source, { from: undefined });
return css;
},
}),
esbuildPluginBrowserslist(browserslist('>0.2%, not dead, not op_mini all, not chrome < 51, not safari < 10, not android < 5, not ie < 12'), {
printUnknownTargets: false,
}),
],
});
// console.log(await esbuild.analyzeMetafile(result.metafile));
fs.writeFileSync('static/meta.json', JSON.stringify(result.metafile));