-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
67 lines (62 loc) · 2.07 KB
/
esbuild.config.js
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
60
61
62
63
64
65
66
67
import esbuild from 'esbuild';
import scss from 'esbuild-plugin-sass';
const watch = process.argv.includes('--watch') && {
onRebuild(error) {
if (error) console.error('[watch] build failed', error);
else console.log('[watch] build finished');
},
};
// see https://github.com/evanw/esbuild/issues/806#issuecomment-779138268
let skipReactImports = {
name: 'skipReactImports',
setup(build) {
build.onResolve({ filter: /^(react(-dom)?|survey-react)$/ }, (args) => {
return {
path: args.path,
namespace: `globalExternal_${args.path}`,
};
});
build.onLoad({ filter: /.*/, namespace: 'globalExternal_react' }, () => {
return {
contents: `module.exports = globalThis.React`,
loader: 'js',
};
});
build.onLoad({ filter: /.*/, namespace: 'globalExternal_react-dom' }, () => {
return {
contents: `module.exports = globalThis.ReactDOM`,
loader: 'js',
};
});
build.onLoad({ filter: /.*/, namespace: 'globalExternal_survey-react' }, () => {
return {
contents: `module.exports = globalThis.Survey`,
loader: 'js',
};
});
},
};
esbuild
.build({
entryPoints: [
'components/toolbar/toolbar.tsx',
'components/sidebar/sidebar.tsx',
'components/report-window/report-window.tsx',
'background.ts',
'styles/global.scss',
'styles/fonts.scss',
],
bundle: true,
// minify: true,
outdir: './lib',
loader: { '.woff': 'file', '.woff2': 'file' },
plugins: [scss(), skipReactImports],
define: {
PLUGIN_NAME: '"Rentgen"',
PLUGIN_URL: '"https://git.internet-czas-dzialac.pl/icd/rentgen"',
},
external: ['react', 'react-dom', 'survey-react'],
watch,
})
.then(() => console.log('Add-on was built'))
.catch(() => process.exit(1));