2021-11-27 21:44:03 +00:00
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
|
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
const isDevelopment = process.env.NODE_ENV !== 'production'
|
|
|
|
|
|
|
|
const API_URL = process.env.API_URL || 'http://localhost:3000'
|
|
|
|
const BASE_URL = process.env.BASE_URL || isDevelopment ? 'http://localhost:3001' : '__BASE_HREF__'
|
|
|
|
const PORT = process.env.PORT || 3001
|
|
|
|
|
2021-11-26 12:40:12 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: './src/index.js',
|
2021-11-27 21:44:03 +00:00
|
|
|
mode: isDevelopment ? 'development' : 'production',
|
|
|
|
cache: isDevelopment && {type: 'filesystem'},
|
|
|
|
devtool: 'eval-cheap-module-source-map',
|
2021-11-26 12:40:12 +00:00
|
|
|
output: {
|
2021-11-27 21:44:03 +00:00
|
|
|
path: path.resolve(__dirname, 'build'),
|
2021-11-26 12:40:12 +00:00
|
|
|
filename: 'bundle.js',
|
|
|
|
},
|
2021-11-27 21:44:03 +00:00
|
|
|
cache: false,
|
2021-11-26 12:40:12 +00:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
|
|
alias: {
|
|
|
|
'mapbox-gl': 'maplibre-gl',
|
2021-11-27 21:44:03 +00:00
|
|
|
'../../theme.config': path.resolve('./src/semantic-ui/theme.config'),
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
modules: ['node_modules', 'src'],
|
|
|
|
},
|
2021-11-27 21:44:03 +00:00
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
base: BASE_URL,
|
|
|
|
meta: {
|
|
|
|
charset: 'utf-8',
|
|
|
|
viewport: 'width=device-width, initial-scale=1',
|
|
|
|
'theme-color': '#000000',
|
|
|
|
description:
|
|
|
|
'Upload the tracks recorded with your OpenBikeSensor device to this portal and participate in the accumulation of Open Data.',
|
|
|
|
},
|
|
|
|
favicon: 'public/favicon.ico',
|
|
|
|
manifest: 'public/manifest.json',
|
|
|
|
}),
|
|
|
|
|
|
|
|
isDevelopment && new ReactRefreshWebpackPlugin(),
|
|
|
|
].filter(Boolean),
|
|
|
|
devServer: {
|
|
|
|
port: PORT,
|
|
|
|
hot: true,
|
|
|
|
compress: true,
|
|
|
|
historyApiFallback: true,
|
|
|
|
static: {
|
|
|
|
directory: path.join(__dirname, 'public'),
|
|
|
|
serveIndex: true,
|
|
|
|
},
|
|
|
|
client: {
|
|
|
|
webSocketURL: `ws://0.0.0.0:${PORT}/ws`,
|
|
|
|
},
|
|
|
|
proxy: {
|
|
|
|
'/api': API_URL,
|
|
|
|
'/login': API_URL,
|
|
|
|
},
|
|
|
|
},
|
2021-11-26 12:40:12 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2021-11-27 21:44:03 +00:00
|
|
|
test: /\.(mjs|js|jsx|ts|tsx)$/,
|
|
|
|
include: path.resolve('./src'),
|
2021-11-26 12:40:12 +00:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2021-11-27 21:44:03 +00:00
|
|
|
babelrc: false,
|
|
|
|
configFile: false,
|
|
|
|
cacheDirectory: true,
|
|
|
|
cacheCompression: false,
|
|
|
|
sourceMaps: true,
|
|
|
|
inputSourceMap: true,
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
isDevelopment && 'react-refresh/babel',
|
|
|
|
[
|
|
|
|
'@babel/plugin-transform-runtime',
|
|
|
|
{
|
|
|
|
corejs: false,
|
|
|
|
regenerator: true,
|
|
|
|
useESModules: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
].filter(Boolean),
|
2021-11-26 12:40:12 +00:00
|
|
|
presets: [
|
2021-11-27 21:44:03 +00:00
|
|
|
[
|
|
|
|
'@babel/preset-react',
|
|
|
|
{
|
|
|
|
development: isDevelopment,
|
|
|
|
runtime: 'automatic',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@babel/preset-typescript',
|
|
|
|
'@babel/preset-env',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
2021-11-27 21:44:03 +00:00
|
|
|
use: ['style-loader', 'css-loader'],
|
|
|
|
sideEffects: true,
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.module\.less$/i,
|
|
|
|
use: [
|
|
|
|
// compiles Less to CSS
|
2021-11-27 21:44:03 +00:00
|
|
|
'style-loader',
|
|
|
|
{loader: 'css-loader', options: {modules: true}},
|
|
|
|
{
|
|
|
|
loader: 'less-loader',
|
|
|
|
options: {
|
|
|
|
lessOptions: {
|
|
|
|
math: 'always',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-11-26 12:40:12 +00:00
|
|
|
],
|
2021-11-27 21:44:03 +00:00
|
|
|
sideEffects: true,
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/i,
|
|
|
|
exclude: /\.module\.less$/i,
|
|
|
|
use: [
|
|
|
|
// compiles Less to CSS
|
2021-11-27 21:44:03 +00:00
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'less-loader',
|
|
|
|
options: {
|
|
|
|
lessOptions: {
|
|
|
|
math: 'always',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-11-26 12:40:12 +00:00
|
|
|
],
|
2021-11-27 21:44:03 +00:00
|
|
|
sideEffects: true,
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
|
|
type: 'asset/resource',
|
|
|
|
},
|
|
|
|
|
2021-11-27 21:44:03 +00:00
|
|
|
{
|
2021-11-26 12:40:12 +00:00
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
|
|
type: 'asset/resource',
|
2021-11-27 21:44:03 +00:00
|
|
|
},
|
2021-11-26 12:40:12 +00:00
|
|
|
|
2021-11-27 21:44:03 +00:00
|
|
|
{
|
|
|
|
scheme: 'data',
|
|
|
|
type: 'asset/resource',
|
2021-11-26 12:40:12 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-11-27 21:44:03 +00:00
|
|
|
}
|