aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/webpack.config.js
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-06-29 11:37:14 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-06-29 11:37:14 +0200
commit272c7c5dd04feb54806b92d88dc1a5029cddc397 (patch)
treedecf6950c10782d124c5a3b6055a09d52f9e5791 /language-web/webpack.config.js
parentFix derived state computer idempotency (diff)
downloadrefinery-272c7c5dd04feb54806b92d88dc1a5029cddc397.tar.gz
refinery-272c7c5dd04feb54806b92d88dc1a5029cddc397.tar.zst
refinery-272c7c5dd04feb54806b92d88dc1a5029cddc397.zip
Webpack build for frontend
Diffstat (limited to 'language-web/webpack.config.js')
-rw-r--r--language-web/webpack.config.js94
1 files changed, 94 insertions, 0 deletions
diff --git a/language-web/webpack.config.js b/language-web/webpack.config.js
new file mode 100644
index 00000000..a44260a1
--- /dev/null
+++ b/language-web/webpack.config.js
@@ -0,0 +1,94 @@
1const path = require('path');
2
3const HtmlWebpackPlugin = require('html-webpack-plugin');
4const MiniCssExtractPlugin = require("mini-css-extract-plugin");
5
6const devMode = process.env.NODE_ENV !== 'production';
7
8module.exports = {
9 mode: devMode ? 'development' : 'production',
10 entry: './src/main/js',
11 output: {
12 path: path.resolve(__dirname, 'src/main/webapp'),
13 publicPath: '/',
14 filename: devMode ? '[name].js' : '[contenthash].js',
15 chunkFilename: devMode ? '[id].js' : '[contenthash].js',
16 },
17 module: {
18 rules: [
19 {
20 test: /\.jsx?$/,
21 include: {
22 and: [path.resolve(__dirname, 'src/main/js')],
23 not: [path.resolve(__dirname, 'src/main/js/xtext')],
24 },
25 loader: 'babel-loader',
26 options: {
27 presets: [
28 ['@babel/preset-env', { targets: 'defaults' }],
29 ],
30 },
31 },
32 {
33 test: /\.scss$/,
34 use: [
35 devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
36 'css-loader',
37 {
38 loader: 'sass-loader',
39 options: {
40 implementation: require.resolve('sass'),
41 },
42 },
43 ]
44 },
45 {
46 test: /\.(gif|png|jpe?g|svg)$/,
47 use: [
48 'file-loader',
49 {
50 loader: 'image-webpack-loader',
51 options: {
52 disable: true,
53 }
54 },
55 ],
56 },
57 ],
58 },
59 resolve: {
60 modules: [
61 'node_modules',
62 path.resolve(__dirname, 'src/main/js'),
63 path.resolve(__dirname, 'src/main/js-gen'),
64 ],
65 extensions: ['.js', '.jsx'],
66 alias: {
67 images: path.resolve(__dirname, 'src/main/images'),
68 },
69 },
70 devtool: devMode ? 'eval' : 'source-map',
71 optimization: {
72 splitChunks: {
73 chunks: 'all',
74 },
75 },
76 plugins: [
77 new MiniCssExtractPlugin({
78 filename: '[contenthash].css',
79 chunkFilename: '[contenthash].css',
80 }),
81 new HtmlWebpackPlugin({
82 template: 'src/main/html/index.html',
83 minify: devMode ? false : {
84 collapseWhitespace: true,
85 removeComments: true,
86 removeOptionalTags: true,
87 removeRedundantAttributes: true,
88 removeScriptTypeAttributes: true,
89 removeStyleLinkTypeAttributes: true,
90 useShortDoctype: true,
91 },
92 }),
93 ],
94};