forked from RTVision/mocha-esbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.esbuildrc.js
50 lines (49 loc) · 1.7 KB
/
.esbuildrc.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
import EsbuildVue from 'esbuild-vue';
import { esbuildPluginNodeExternals } from 'esbuild-plugin-node-externals';
import DynamicImport from './esbuild-dynamic-import.js';
// Example working esbuild config I use in my companies codebase
// reference at https://esbuild.github.io/api/#build-api
export default {
target: 'node16',
format: 'esm',
platform: 'node',
mainFields: ['module', 'main', 'browser'],
external: [
'canvas',
'worker-loader!pdfjs-dist/es5/build/pdf.worker.js',
'pdfmake',
'xlsx'
],
plugins: [
// see https://github.com/RtVision/esbuild-dynamic-import
DynamicImport({ transformExtensions: ['.vue'], changeRelativeToAbsolute: true }),
// Current plugin is for Vue 2 SFC https://www.npmjs.com/package/esbuild-vue
// for Vue 3 SFC https://www.npmjs.com/package/esbuild-plugin-vue3
EsbuildVue(),
// since we are running tests in nodejs only include the packages that need
// to be processed by esbuild for whatever reason. That way the bundled file
// size can be decreased and defer to node at runtime to load the exclude packages.
// A note, including a package down below will likely pull in its dependencies also
// For example vue-pdf was then pulling in pdfjs-dst worker, I had to add that
// to the externals array above to explicitly disallow bundling that in
esbuildPluginNodeExternals({
include: [
'bootstrap-vue',
'vue-typeahead-bootstrap',
'vue-pdf',
'vue-datetime',
'@amcharts/amcharts4',
'rtvision-app-common',
'ajv',
'ol-layerswitcher',
'@vue/composition-api',
'ol',
'@shopify/draggable'
]
})
],
define: {
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.TEST_ENV': JSON.stringify(true)
}
}