-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.mjs
59 lines (53 loc) · 1.58 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import esbuild from 'esbuild';
import extensibilityMap from '@neos-project/neos-ui-extensibility/extensibilityMap.json' assert { type: 'json' };
import { cssModules } from 'esbuild-plugin-lightningcss-modules';
const baseOptions = {
logLevel: 'info',
bundle: true,
minify: process.argv.includes('--production'),
sourcemap: !process.argv.includes('--production'),
target: 'es2020',
legalComments: 'none',
};
const scriptOptions = {
...baseOptions,
entryPoints: ['Resources/Private/Assets/*.js'],
outdir: 'Resources/Public/Scripts',
format: 'iife',
};
const moduleOptions = {
...baseOptions,
entryPoints: ['Resources/Private/Assets/*.mjs'],
outdir: 'Resources/Public/Modules',
format: 'esm',
splitting: true,
};
const editorOptions = {
...baseOptions,
entryPoints: { Metadata: 'Resources/Private/MetadataEditor/manifest.js' },
outdir: 'Resources/Public/Plugin',
format: 'iife',
loader: {
'.js': 'tsx',
'.pcss': 'css',
},
alias: extensibilityMap,
plugins: [
cssModules({
targets: {
chrome: 80, // aligns somewhat to es2020
},
cssModules: {
dashedIdents: true,
pattern: 'jonnitto-prettyembed-[hash]-[local]',
},
}),
],
};
async function watch(options) {
const context = await esbuild.context(options);
await context.watch();
}
[scriptOptions, moduleOptions, editorOptions].forEach((options) => {
process.argv.includes('--watch') ? watch(options) : esbuild.build(options);
});