-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
48 lines (43 loc) · 1.18 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
const minimist = require("minimist");
const dotenv = require("dotenv");
const path = require("path");
const browserslist = require("browserslist");
const esbuild = require("esbuild");
const esbuildRailsPlugin = require("esbuild-rails");
const esbuildBrowserslistPlugin =
require("esbuild-plugin-browserslist").esbuildPluginBrowserslist;
// Parse CLI arguments.
const { minify, watch } = minimist(process.argv);
// Define entry points.
const entryPoints = ["application.ts"];
// Set environment.
dotenv.config();
// Build scripts, and output to app/assets/builds.
esbuild
.build({
entryPoints: entryPoints.map(name =>
path.join(process.cwd(), `app/javascript/${name}`),
),
define: {
global: "window",
},
bundle: true,
minify,
sourcemap: true,
outdir: path.join(process.cwd(), "app/assets/builds"),
loader: {
".png": "file",
".jpg": "file",
".svg": "file",
".woff": "file",
".woff2": "file",
".ttf": "file",
".eot": "file",
},
watch,
plugins: [
esbuildRailsPlugin(),
esbuildBrowserslistPlugin(browserslist(), { printUnknownTargets: false }),
],
})
.catch(() => process.exit(1));