aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/webpack.config.js
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-22 19:54:51 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-22 19:54:51 +0200
commit8cbf8fdcfdceab8a330bdc82e4260a55c125c37d (patch)
tree0354dcc6ce0704fc953e7665ecfcc700609549a2 /language-web/webpack.config.js
parentBump Material-UI version (diff)
downloadrefinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.tar.gz
refinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.tar.zst
refinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.zip
Covert language-web to TypeScript
Diffstat (limited to 'language-web/webpack.config.js')
-rw-r--r--language-web/webpack.config.js83
1 files changed, 56 insertions, 27 deletions
diff --git a/language-web/webpack.config.js b/language-web/webpack.config.js
index 8f0fb3f2..0b89298c 100644
--- a/language-web/webpack.config.js
+++ b/language-web/webpack.config.js
@@ -13,7 +13,7 @@ const outputPath = path.resolve(__dirname, 'build/webpack', currentNodeEnv);
13const portNumberOrElse = (envName, fallback) => { 13const portNumberOrElse = (envName, fallback) => {
14 const value = process.env[envName]; 14 const value = process.env[envName];
15 return value ? parseInt(value) : fallback; 15 return value ? parseInt(value) : fallback;
16} 16};
17const listenHost = process.env['LISTEN_HOST'] || 'localhost'; 17const listenHost = process.env['LISTEN_HOST'] || 'localhost';
18const listenPort = portNumberOrElse('LISTEN_PORT', 1313); 18const listenPort = portNumberOrElse('LISTEN_PORT', 1313);
19const apiHost = process.env['API_HOST'] || listenHost; 19const apiHost = process.env['API_HOST'] || listenHost;
@@ -21,6 +21,23 @@ const apiPort = portNumberOrElse('API_PORT', 1312);
21const publicHost = process.env['PUBLIC_HOST'] || listenHost; 21const publicHost = process.env['PUBLIC_HOST'] || listenHost;
22const publicPort = portNumberOrElse('PUBLIC_PORT', listenPort); 22const publicPort = portNumberOrElse('PUBLIC_PORT', listenPort);
23 23
24const resolveSources = sources => path.resolve(__dirname, 'src', sources);
25const resolveGenerated = sources => path.resolve(__dirname, 'build/generated/sources', sources);
26const mainJsSources = resolveSources('main/js');
27const babelLoaderFilters = {
28 include: [mainJsSources],
29 exclude: [resolveSources('main/js/xtext')],
30};
31const babelPresets = [
32 [
33 '@babel/preset-env',
34 {
35 targets: 'defaults',
36 },
37 ],
38 '@babel/preset-react',
39];
40
24module.exports = { 41module.exports = {
25 mode: devMode ? 'development' : 'production', 42 mode: devMode ? 'development' : 'production',
26 entry: './src/main/js', 43 entry: './src/main/js',
@@ -35,19 +52,10 @@ module.exports = {
35 rules: [ 52 rules: [
36 { 53 {
37 test: /\.jsx?$/i, 54 test: /\.jsx?$/i,
38 include: [path.resolve(__dirname, 'src/main/js')], 55 ...babelLoaderFilters,
39 exclude: [path.resolve(__dirname, 'src/main/js/xtext')],
40 loader: 'babel-loader', 56 loader: 'babel-loader',
41 options: { 57 options: {
42 presets: [ 58 presets: babelPresets,
43 [
44 '@babel/preset-env',
45 {
46 targets: 'defaults',
47 },
48 ],
49 '@babel/preset-react',
50 ],
51 plugins: [ 59 plugins: [
52 [ 60 [
53 '@babel/plugin-proposal-class-properties', 61 '@babel/plugin-proposal-class-properties',
@@ -62,6 +70,26 @@ module.exports = {
62 }, 70 },
63 }, 71 },
64 { 72 {
73 test: /.tsx?$/i,
74 ...babelLoaderFilters,
75 loader: 'babel-loader',
76 options: {
77 presets: [
78 ...babelPresets,
79 [
80 '@babel/preset-typescript',
81 {
82 isTSX: true,
83 allExtensions: true,
84 allowDeclareFields: true,
85 onlyRemoveTypeImports: true,
86 optimizeConstEnums: true,
87 },
88 ]
89 ],
90 },
91 },
92 {
65 test: /\.scss$/i, 93 test: /\.scss$/i,
66 use: [ 94 use: [
67 devMode ? 'style-loader' : MiniCssExtractPlugin.loader, 95 devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
@@ -83,29 +111,24 @@ module.exports = {
83 disable: true, 111 disable: true,
84 } 112 }
85 }, 113 },
86 {
87 loader: 'url-loader',
88 options: {
89 limit: 256,
90 },
91 },
92 ], 114 ],
115 type: 'asset',
93 }, 116 },
94 { 117 {
95 test: /\.woff2?$/i, 118 test: /\.woff2?$/i,
96 loader: 'file-loader', 119 type: 'asset/resource',
97 }, 120 },
98 ], 121 ],
99 }, 122 },
100 resolve: { 123 resolve: {
101 modules: [ 124 modules: [
102 'node_modules', 125 'node_modules',
103 path.resolve(__dirname, 'src/main/js'), 126 mainJsSources,
104 path.resolve(__dirname, 'build/generated/sources/xtext/js'), 127 resolveGenerated('xtext/js'),
105 ], 128 ],
106 extensions: ['.js', '.jsx'], 129 extensions: ['.js', '.jsx', '.ts', '.tsx'],
107 alias: { 130 alias: {
108 images: path.resolve(__dirname, 'src/main/images'), 131 images: resolveSources('main/images'),
109 }, 132 },
110 }, 133 },
111 devtool: devMode ? 'inline-source-map' : 'source-map', 134 devtool: devMode ? 'inline-source-map' : 'source-map',
@@ -115,16 +138,22 @@ module.exports = {
115 }, 138 },
116 }, 139 },
117 devServer: { 140 devServer: {
118 contentBase: outputPath, 141 client: {
142 logging: 'info',
143 overlay: true,
144 progress: true,
145 webSocketURL: {
146 hostname: publicHost,
147 port: publicPort,
148 protocol: publicPort === 443 ? 'wss' : 'ws',
149 },
150 },
119 compress: true, 151 compress: true,
120 host: listenHost, 152 host: listenHost,
121 port: listenPort, 153 port: listenPort,
122 proxy: { 154 proxy: {
123 '/xtext-service': `${apiPort === 443 ? 'https' : 'http'}://${apiHost}:${apiPort}`, 155 '/xtext-service': `${apiPort === 443 ? 'https' : 'http'}://${apiHost}:${apiPort}`,
124 }, 156 },
125 public: `${publicHost}:${publicPort}`,
126 sockHost: publicHost,
127 sockPort: publicPort,
128 }, 157 },
129 plugins: [ 158 plugins: [
130 new MiniCssExtractPlugin({ 159 new MiniCssExtractPlugin({