mirror of
https://github.com/urbit/shrub.git
synced 2024-12-11 11:02:25 +03:00
137 lines
3.4 KiB
JavaScript
137 lines
3.4 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, '../public'),
|
|
hot: true,
|
|
port: 9000,
|
|
host: '0.0.0.0',
|
|
disableHostCheck: true,
|
|
historyApiFallback: {
|
|
disableDotRule: true
|
|
},
|
|
publicPath: '/apps/landscape/'
|
|
};
|
|
|
|
const router = _.mapKeys(urbitrc.FLEET || {}, (value, key) => `${key}.localhost:9000`);
|
|
|
|
if(urbitrc.URL) {
|
|
devServer = {
|
|
...devServer,
|
|
index: 'index.html',
|
|
// headers: {
|
|
// 'Service-Worker-Allowed': '/'
|
|
// },
|
|
proxy: [
|
|
{
|
|
context: (path) => {
|
|
console.log(path);
|
|
if(path === '/apps/landscape/desk.js') {
|
|
return true;
|
|
}
|
|
return !path.startsWith('/apps/landscape');
|
|
},
|
|
changeOrigin: true,
|
|
target: urbitrc.URL,
|
|
router
|
|
}
|
|
]
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
mode: 'development',
|
|
entry: {
|
|
app: './src/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'
|
|
]
|
|
},
|
|
{
|
|
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
use: [
|
|
{
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
outputPath: 'fonts/'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
]
|
|
},
|
|
resolve: {
|
|
extensions: ['.js', '.ts', '.tsx']
|
|
},
|
|
devtool: 'inline-source-map',
|
|
devServer: devServer,
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env.LANDSCAPE_SHORTHASH': JSON.stringify(GIT_DESC),
|
|
'process.env.LANDSCAPE_STORAGE_VERSION': JSON.stringify(Date.now()),
|
|
'process.env.LANDSCAPE_LAST_WIPE': JSON.stringify('2021-10-20'),
|
|
}),
|
|
|
|
// new CleanWebpackPlugin(),
|
|
new HtmlWebpackPlugin({
|
|
title: 'Groups',
|
|
template: './public/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/landscape/',
|
|
globalObject: 'this'
|
|
},
|
|
optimization: {
|
|
minimize: false,
|
|
usedExports: true
|
|
}
|
|
};
|