2020-04-24 02:08:47 +03:00
|
|
|
const path = require('path');
|
2021-02-08 04:02:52 +03:00
|
|
|
const webpack = require('webpack');
|
2021-09-06 07:06:32 +03:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2020-04-30 01:48:25 +03:00
|
|
|
// const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
|
|
const urbitrc = require('./urbitrc');
|
2020-10-13 08:04:46 +03:00
|
|
|
const _ = require('lodash');
|
2021-03-31 02:58:59 +03:00
|
|
|
const { execSync } = require('child_process');
|
|
|
|
|
|
|
|
const GIT_DESC = execSync('git describe --always', { encoding: 'utf8' }).trim();
|
|
|
|
|
2020-07-15 08:04:14 +03:00
|
|
|
let devServer = {
|
2021-09-17 03:49:31 +03:00
|
|
|
contentBase: path.join(__dirname, '../public'),
|
2020-07-15 08:04:14 +03:00
|
|
|
hot: true,
|
|
|
|
port: 9000,
|
2020-09-26 02:13:29 +03:00
|
|
|
host: '0.0.0.0',
|
|
|
|
disableHostCheck: true,
|
2021-09-17 03:49:31 +03:00
|
|
|
historyApiFallback: {
|
|
|
|
disableDotRule: true
|
|
|
|
},
|
2021-09-06 07:06:32 +03:00
|
|
|
publicPath: '/apps/landscape/'
|
2020-07-16 18:40:35 +03:00
|
|
|
};
|
2020-07-15 08:04:14 +03:00
|
|
|
|
2020-10-13 08:04:46 +03:00
|
|
|
const router = _.mapKeys(urbitrc.FLEET || {}, (value, key) => `${key}.localhost:9000`);
|
|
|
|
|
2020-07-15 08:04:14 +03:00
|
|
|
if(urbitrc.URL) {
|
|
|
|
devServer = {
|
2020-07-16 18:40:35 +03:00
|
|
|
...devServer,
|
2021-09-06 07:06:32 +03:00
|
|
|
index: 'index.html',
|
2021-09-21 23:13:46 +03:00
|
|
|
// headers: {
|
|
|
|
// 'Service-Worker-Allowed': '/'
|
|
|
|
// },
|
2021-09-06 07:06:32 +03:00
|
|
|
proxy: [
|
|
|
|
{
|
|
|
|
context: (path) => {
|
|
|
|
console.log(path);
|
|
|
|
if(path === '/apps/landscape/desk.js') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !path.startsWith('/apps/landscape');
|
|
|
|
},
|
2020-10-13 08:04:46 +03:00
|
|
|
changeOrigin: true,
|
2020-07-16 02:32:11 +03:00
|
|
|
target: urbitrc.URL,
|
2021-09-06 07:06:32 +03:00
|
|
|
router
|
2020-10-13 08:04:46 +03:00
|
|
|
}
|
2021-09-06 07:06:32 +03:00
|
|
|
]
|
2020-07-16 18:40:35 +03:00
|
|
|
};
|
2020-07-15 08:04:14 +03:00
|
|
|
}
|
|
|
|
|
2020-04-24 02:08:47 +03:00
|
|
|
module.exports = {
|
2020-04-30 01:48:25 +03:00
|
|
|
mode: 'development',
|
2020-04-24 02:08:47 +03:00
|
|
|
entry: {
|
2021-09-06 07:06:32 +03:00
|
|
|
app: './src/index.js'
|
2021-03-29 22:20:59 +03:00
|
|
|
// serviceworker: './src/serviceworker.js'
|
2020-04-24 02:08:47 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2020-06-22 07:59:02 +03:00
|
|
|
test: /\.(j|t)sx?$/,
|
2020-04-24 02:08:47 +03:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2021-03-11 07:22:39 +03:00
|
|
|
presets: ['@babel/preset-env', '@babel/typescript', ['@babel/preset-react', {
|
|
|
|
runtime: 'automatic',
|
|
|
|
development: true,
|
2021-09-06 07:06:32 +03:00
|
|
|
importSource: '@welldone-software/why-did-you-render'
|
2021-03-11 07:22:39 +03:00
|
|
|
}]],
|
2020-04-24 02:08:47 +03:00
|
|
|
plugins: [
|
2020-07-15 23:42:56 +03:00
|
|
|
'@babel/transform-runtime',
|
2020-04-24 02:08:47 +03:00
|
|
|
'@babel/plugin-proposal-object-rest-spread',
|
2020-05-01 05:54:03 +03:00
|
|
|
'@babel/plugin-proposal-optional-chaining',
|
2020-07-15 08:04:14 +03:00
|
|
|
'@babel/plugin-proposal-class-properties',
|
|
|
|
'react-hot-loader/babel'
|
2020-04-24 02:08:47 +03:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2021-11-11 03:30:25 +03:00
|
|
|
exclude: /node_modules\/(?!(@tlon\/indigo-dark|@tlon\/indigo-light|@tlon\/indigo-react|@urbit\/api)\/).*/
|
2020-04-24 02:08:47 +03:00
|
|
|
},
|
2020-04-30 01:48:25 +03:00
|
|
|
{
|
2020-04-30 02:02:59 +03:00
|
|
|
test: /\.css$/i,
|
2020-04-30 01:48:25 +03:00
|
|
|
use: [
|
|
|
|
// Creates `style` nodes from JS strings
|
|
|
|
'style-loader',
|
|
|
|
// Translates CSS into CommonJS
|
|
|
|
'css-loader',
|
|
|
|
// Compiles Sass to CSS
|
|
|
|
'sass-loader'
|
|
|
|
]
|
2021-09-28 07:14:33 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'fonts/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-04-30 01:48:25 +03:00
|
|
|
}
|
2021-09-28 07:14:33 +03:00
|
|
|
|
2020-04-30 01:48:25 +03:00
|
|
|
]
|
2020-04-24 02:08:47 +03:00
|
|
|
},
|
|
|
|
resolve: {
|
2020-06-22 07:59:02 +03:00
|
|
|
extensions: ['.js', '.ts', '.tsx']
|
2020-04-24 02:08:47 +03:00
|
|
|
},
|
|
|
|
devtool: 'inline-source-map',
|
2020-07-15 08:04:14 +03:00
|
|
|
devServer: devServer,
|
2020-04-24 02:08:47 +03:00
|
|
|
plugins: [
|
2021-02-08 04:02:52 +03:00
|
|
|
new webpack.DefinePlugin({
|
2021-03-31 02:58:59 +03:00
|
|
|
'process.env.LANDSCAPE_SHORTHASH': JSON.stringify(GIT_DESC),
|
2021-10-22 00:36:31 +03:00
|
|
|
'process.env.LANDSCAPE_STORAGE_VERSION': JSON.stringify(Date.now()),
|
|
|
|
'process.env.LANDSCAPE_LAST_WIPE': JSON.stringify('2021-10-20'),
|
2021-09-06 07:06:32 +03:00
|
|
|
}),
|
2021-02-08 04:02:52 +03:00
|
|
|
|
2020-04-28 23:49:39 +03:00
|
|
|
// new CleanWebpackPlugin(),
|
2021-09-06 07:06:32 +03:00
|
|
|
new HtmlWebpackPlugin({
|
2021-09-24 03:02:44 +03:00
|
|
|
title: 'Groups',
|
2021-09-06 07:06:32 +03:00
|
|
|
template: './public/index.html'
|
|
|
|
})
|
2020-04-24 02:08:47 +03:00
|
|
|
],
|
2020-06-05 05:50:14 +03:00
|
|
|
watch: true,
|
2020-04-24 02:08:47 +03:00
|
|
|
output: {
|
2021-01-28 08:30:48 +03:00
|
|
|
filename: (pathData) => {
|
|
|
|
return pathData.chunk.name === 'app' ? 'index.js' : '[name].js';
|
|
|
|
},
|
|
|
|
chunkFilename: '[name].js',
|
2020-06-05 05:50:14 +03:00
|
|
|
path: path.resolve(__dirname, '../dist'),
|
2021-09-13 14:03:13 +03:00
|
|
|
publicPath: '/apps/landscape/',
|
2021-01-28 08:30:48 +03:00
|
|
|
globalObject: 'this'
|
2020-04-24 02:08:47 +03:00
|
|
|
},
|
2020-04-28 23:49:39 +03:00
|
|
|
optimization: {
|
2020-04-30 01:48:25 +03:00
|
|
|
minimize: false,
|
|
|
|
usedExports: true
|
2020-04-28 23:49:39 +03:00
|
|
|
}
|
2020-04-24 02:08:47 +03:00
|
|
|
};
|