-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathesbuild.config.mjs
More file actions
33 lines (29 loc) · 1.07 KB
/
esbuild.config.mjs
File metadata and controls
33 lines (29 loc) · 1.07 KB
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
import esbuild from 'esbuild';
import postCssPlugin from 'esbuild-postcss';
const isProduction = process.env.NODE_ENV === 'production';
// 共通の設定オブジェクトを作成
const commonConfig = {
bundle: true,
sourcemap: true,
loader: { '.png': 'file', '.svg': 'file' },
plugins: [postCssPlugin()],
target: ['es2015'],
logLevel: 'info',
define: { 'process.env.NODE_ENV': isProduction ? '"production"' : '"development"' },
};
// JavaScriptのビルド設定
esbuild.build({
...commonConfig,
entryPoints: ['app/javascript/packs/index.tsx'],
outdir: 'assets/javascripts', // 出力ディレクトリ
outbase: 'app/javascript/packs', // エントリーポイントからの共通パス
entryNames: '[name]', // 出力ファイル名をエントリーポイントのファイル名にする
}).catch(() => process.exit(1));
// CSSのビルド設定
esbuild.build({
...commonConfig,
entryPoints: ['app/javascript/packs/index.css'],
outdir: 'assets/stylesheets',
outbase: 'app/javascript/packs',
entryNames: '[name]',
}).catch(() => process.exit(1));