-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
102 lines (100 loc) · 3.04 KB
/
webpack.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const path = require("path")
const webpack = require("webpack")
// CSSを.cssファイルに切り出す
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// CSSのみを含むエントリーから、exportされたJavaScriptファイルを削除する
// この例では、entry.customは対応する空のcustom.jsファイルを作成する
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
process.env.RAILS_ENV = process.env.RAILS_ENV || 'development'
process.env.NODE_ENV = process.env.NODE_ENV || process.env.RAILS_ENV
module.exports = {
mode: ['development', 'production'].includes(process.env.NODE_ENV) ? process.env.NODE_ENV : 'development',
devtool: "source-map",
optimization: {
moduleIds: 'deterministic',
},
entry: {
application: [
"./app/javascript/packs/application.js",
'./app/javascript/stylesheets/application.scss',
],
cndw2024: [
"./app/javascript/packs/cndw2024.js",
'./app/javascript/stylesheets/cndw2024.scss',
],
cnds2024: [
"./app/javascript/packs/cnds2024.js",
'./app/javascript/stylesheets/cnds2024.scss',
],
cndo2021: [
"./app/javascript/packs/cndo2021.js",
'./app/javascript/stylesheets/cndo2021.scss',
],
cndt2023: [
"./app/javascript/packs/cndt2023.js",
'./app/javascript/stylesheets/cndt2023.scss',
],
cndf2023: [
"./app/javascript/packs/cndf2023.js",
'./app/javascript/stylesheets/cndf2023.scss',
],
cicd2021: [
"./app/javascript/packs/cicd2021.js",
'./app/javascript/stylesheets/cicd2021.scss',
],
talks: [
"./app/javascript/packs/talks.js",
],
vote_cfp: [
"./app/javascript/packs/vote_cfp.js",
],
'admin/tracks': [
"./app/javascript/packs/admin/tracks/index.js",
],
'admin/tracks/media_live': [
"./app/javascript/packs/admin/tracks/media_live.js",
],
'admin/tracks/tracks_control': [
"./app/javascript/packs/admin/tracks/tracks_control.js",
],
'chat/index': [
"./app/javascript/packs/chat/index.js",
],
'tracks/waiting_channel': [
"./app/javascript/packs/tracks/waiting_channel.js",
],
'tracks/track_channel': [
"./app/javascript/packs/tracks/track_channel.js",
]
},
module: {
rules: [
// ローダーを含むCSS/SASS/SCSSルールをここに追加する
{
test: /\.(?:sa|sc|c)ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.(png|jpe?g|gif|eot|woff2|woff|ttf|svg)$/i,
use: 'file-loader',
},
],
},
resolve: {
// 追加のファイル種別をここに追加する
extensions: ['.js', '.jsx', '.scss', '.css'],
},
output: {
filename: "[name].js",
sourceMapFilename: "[file].map",
chunkFormat: "module",
path: path.resolve(__dirname, "app/assets/builds"),
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin(),
]
}