forked from Albert-Markdown-Editor/Albert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.mjs
36 lines (35 loc) · 1.46 KB
/
esbuild.config.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
import path from 'path'
import esbuild from 'esbuild'
import rails from 'esbuild-rails'
import babel from 'esbuild-plugin-babel'
esbuild
.build({
bundle: true,
// Path to application.js folder
absWorkingDir: path.join(process.cwd(), 'app/javascript'),
// Application.js file, used by Rails to bundle all JS Rails code
entryPoints: ['application.js'],
// Destination of JS bundle, points to the Rails JS Asset folder
outdir: path.join(process.cwd(), 'app/assets/builds'),
// Enables watch option. Will regenerate JS bundle if files are changed
watch: process.argv.includes('--watch'),
// Split option is disabled, only needed when using multiple input files
// More information: https://esbuild.github.io/api/#splitting (change it if using multiple inputs)
splitting: false,
chunkNames: 'chunks/[name]-[hash]',
// Remove unused JS methods
treeShaking: true,
// Build command log output: https://esbuild.github.io/api/#log-level
logLevel: 'info',
// Set of ESLint plugins
plugins: [
// Plugin to easily import Rails JS files, such as Stimulus controllers and channels
// https://github.com/excid3/esbuild-rails
rails(),
// Configures bundle with Babel. Babel configuration defined in babel.config.js
// Babel translates JS code to make it compatible with older JS versions.
// https://github.com/nativew/esbuild-plugin-babel
babel()
]
})
.catch(() => process.exit(1))