shrub/pkg/interface/webterm/config/webpack.dev.js
Fang a675dbda44
webterm: web interface only, herm stays in base
As per earlier discussion with @belisarius222.
2021-09-14 15:07:22 +02:00

107 lines
2.7 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const urbitrc = require('./urbitrc');
const _ = require('lodash');
const { execSync } = require('child_process');
const GIT_DESC = execSync('git describe --always', { encoding: 'utf8' }).trim();
let devServer = {
contentBase: path.join(__dirname, '../dist'),
hot: true,
port: 9000,
host: '0.0.0.0',
disableHostCheck: true,
historyApiFallback: true,
publicPath: '/apps/webterm/'
};
const router = _.mapKeys(urbitrc.FLEET || {}, (value, key) => `${key}.localhost:9000`);
if(urbitrc.URL) {
devServer = {
...devServer,
index: 'index.html',
proxy: [{
changeOrigin: true,
target: urbitrc.URL,
router,
context: (path) => {
return !path.startsWith('/apps/webterm');
}
}]
};
}
module.exports = {
mode: 'development',
entry: {
app: './index.js'
// serviceworker: './src/serviceworker.js'
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/typescript', ['@babel/preset-react', {
runtime: 'automatic',
development: true,
importSource: '@welldone-software/why-did-you-render'
}]],
plugins: [
'@babel/transform-runtime',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties',
'react-hot-loader/babel'
]
}
},
exclude: /node_modules\/(?!(@tlon\/indigo-dark|@tlon\/indigo-light|@tlon\/indigo-react)\/).*/
},
{
test: /\.css$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader'
]
}
]
},
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
devtool: 'inline-source-map',
devServer: devServer,
plugins: [
// new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'Terminal',
template: './index.html'
})
],
watch: true,
output: {
filename: (pathData) => {
return pathData.chunk.name === 'app' ? 'index.js' : '[name].js';
},
chunkFilename: '[name].js',
path: path.resolve(__dirname, '../dist'),
publicPath: '/apps/webterm/',
globalObject: 'this'
},
optimization: {
minimize: false,
usedExports: true
}
};