-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
121 lines (116 loc) · 3.26 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const path = require('path')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const plugins = [new ForkTsCheckerWebpackPlugin()]
const makeConfig = (basedir, componentName) => {
const env = process.env.NODE_ENV || 'development'
const devtool = env === 'production' ? 'source-map' : 'eval'
return {
mode: env,
devtool,
output: {
path: path.resolve(basedir, `../server/resources/public/${componentName}`),
filename: 'js/[name].js',
},
module: {
rules: [
{
test: /\.(ts)x?$/,
exclude: /node_modules/,
loader: 'ts-loader',
},
{
test: /\.jsx?$/,
include: ['web/', '../soresu-form/web/'].map((m) => path.resolve(basedir, m)),
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: {
auto: true,
localIdentName: '[local]__[hash:base64]',
},
},
},
{ loader: 'less-loader' },
],
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
},
],
},
{
test: /\.(?:png|gif|jpe?g|svg)$/,
type: 'asset/inline',
},
],
},
plugins,
resolve: {
alias: {
'soresu-form': path.resolve(basedir, '../soresu-form'),
},
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /soresu-form/,
name: 'commons',
chunks: 'all',
},
},
},
},
}
}
const virkailijaConfig = Object.assign(
{},
makeConfig(path.resolve(__dirname, 'va-virkailija'), 'virkailija'),
{
entry: {
app: path.resolve(
__dirname,
'va-virkailija/web/va/hakemusten-arviointi-page/HakemustenArviointiApp.tsx'
),
adminApp: path.resolve(
__dirname,
'va-virkailija/web/va/hakujen-hallinta-page/HakujenHallintaApp.tsx'
),
summaryApp: path.resolve(__dirname, 'va-virkailija/web/va/yhteenveto-page/YhteenvetoApp.jsx'),
login: path.resolve(__dirname, 'va-virkailija/web/va/login-page/Login.jsx'),
codeValues: path.resolve(
__dirname,
'va-virkailija/web/va/koodienhallinta-page/KoodienhallintaApp.tsx'
),
search: path.resolve(__dirname, 'va-virkailija/web/va/search-page/SearchApp.tsx'),
},
}
)
const hakijaConfig = Object.assign({}, makeConfig(path.resolve(__dirname, 'va-hakija'), 'hakija'), {
entry: {
app: path.resolve(__dirname, 'va-hakija/web/va/VaApp.tsx'),
selvitysApp: path.resolve(__dirname, 'va-hakija/web/va/SelvitysApp.tsx'),
login: path.resolve(__dirname, 'va-hakija/web/va/VaLogin.tsx'),
muutoshakemusApp: path.resolve(
__dirname,
'va-hakija/web/va/muutoshakemus/MuutoshakemusApp.tsx'
),
},
})
module.exports = [hakijaConfig, virkailijaConfig]