This commit is contained in:
notgne2 2020-04-05 22:26:49 -07:00
parent fecfc359f3
commit 06542feef4
6 changed files with 241 additions and 0 deletions

BIN
data/images/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

1
node_modules Symbolic link
View File

@ -0,0 +1 @@
/nix/store/shdrgyl1s3ljcpbhnzypff3q5y1b5zm8-gen2.space-node-sources/node_modules

BIN
registry.dat Normal file

Binary file not shown.

45
template.html Normal file
View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>gen2.space</title>
<link rel="apple-touch-icon" sizes="57x57" href="/appdata/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/appdata/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/appdata/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/appdata/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/appdata/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/appdata/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/appdata/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/appdata/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="167x167" href="/appdata/apple-touch-icon-167x167.png">
<link rel="apple-touch-icon" sizes="180x180" href="/appdata/apple-touch-icon-180x180.png">
<link rel="apple-touch-icon" sizes="1024x1024" href="/appdata/apple-touch-icon-1024x1024.png">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" href="/appdata/apple-touch-startup-image-320x460.png">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" href="/appdata/apple-touch-startup-image-640x920.png">
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="/appdata/apple-touch-startup-image-640x1096.png">
<link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" href="/appdata/apple-touch-startup-image-750x1294.png">
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)" href="/appdata/apple-touch-startup-image-1182x2208.png">
<link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)" href="/appdata/apple-touch-startup-image-1242x2148.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)" href="/appdata/apple-touch-startup-image-748x1024.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" href="/appdata/apple-touch-startup-image-1496x2048.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" href="/appdata/apple-touch-startup-image-768x1004.png">
<link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" href="/appdata/apple-touch-startup-image-1536x2008.png">
<link rel="icon" type="image/png" sizes="16x16" href="/appdata/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/appdata/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="228x228" href="/appdata/coast-228x228.png">
<link rel="manifest" href="/appdata/manifest.json">
<link rel="shortcut icon" href="/appdata/favicon.ico">
<link rel="yandex-tableau-widget" href="/appdata/yandex-browser-manifest.json">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title">
<meta name="application-name" content="gen2.space">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-TileColor" content="#fff">
<meta name="msapplication-TileImage" content="/appdata/mstile-144x144.png">
<meta name="msapplication-config" content="/appdata/browserconfig.xml">
<meta name="theme-color" content="#004400">
</head>
<body>
</body>
</html>

4
wand.js Normal file
View File

@ -0,0 +1,4 @@
document.body.innerHTML = ''
const sourceTarget = document.createElement('script')
sourceTarget.src = '/main.js'
document.body.appendChild(sourceTarget)

191
webpack.config.js Normal file
View File

@ -0,0 +1,191 @@
const ROUTES = ["/","/about","/404","/posts","/posts/viveahk","/posts/librebasics"]
const PRETTY_NAME = "gen2.space"
const DESCRIPTION = "notgne2's shitty pages"
const THEME_COLOR = "#004400"
const BACKGROUND_COLOR = "#220044"
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const { InjectManifest } = require('workbox-webpack-plugin')
const ImageminPlugin = require('imagemin-webpack-plugin').default
const ImageminWebpWebpackPlugin = require('imagemin-webp-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const { JSDOM } = require('jsdom')
const tempy = require('tempy')
const fs = require('fs')
const webpack = require('webpack')
const magicFile = (text) => {
const p = tempy.file()
fs.writeFileSync(p, text)
return p
}
const jsMin = {
mangle: true,
compress: {
keep_fargs: false,
pure_getters: true,
pure_funcs: ['F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9'],
unsafe: true,
ecma: 6,
unsafe_comps: true,
unsafe_arrows: true,
}
}
const htmlMin = {
minifyCSS: {
compatibility: 'ie9',
level: 2
},
minifyJS: jsMin,
collapseBooleanAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeComments: true,
sortAttributes: true,
sortClassName: true,
}
const productionPlugins = [
new InjectManifest({
importWorkboxFrom: 'local',
swSrc: magicFile(`
workbox.core.skipWaiting();
workbox.core.clientsClaim();
workbox.precaching.cleanupOutdatedCaches()
workbox.routing.registerNavigationRoute('/index.html');
workbox.precaching.precacheAndRoute(self.__precacheManifest);
`),
swDest: 'sw.js',
}),
new ImageminPlugin({
jpegtran: { progressive: true },
svgo: null,
}),
new ImageminWebpWebpackPlugin({
config: [{
test: /\.jpe?g/,
options: {
force: true,
quality: 75
}
}, {
test: /\.l\.png/,
options: {
force: true,
quality: 75
}
}, {
test: /\.png/,
options: {
force: true,
lossless: true
}
}],
overrideExtension: false,
detailedLogs: false,
silent: true,
strict: true,
}),
new FaviconsWebpackPlugin({
logo: path.join(__dirname, 'data', 'images', 'icon.png'),
inject: false, // manually in our template for now cos its fuckd
mode: 'webapp',
prefix: 'appdata',
favicons: {
appName: PRETTY_NAME,
appDescription: DESCRIPTION,
background: BACKGROUND_COLOR,
theme_color: THEME_COLOR,
}
}),
];
let plugins = (env, argv) => [
new webpack.HotModuleReplacementPlugin(),
new CopyPlugin([{ from: 'data', to: 'data' }, { from: 'wand.js', to: 'wand.js' }]),
new HtmlWebpackPlugin({
hash: true,
inject: true,
minify: argv.mode == 'production' ? htmlMin : false,
template: './template.html',
meta: {
viewport: 'width=320, initial-scale=1, maximum-scale=5',
description: DESCRIPTION,
}
}),
];
module.exports = (env, argv) => ({
target: 'web',
externals: {
svgo: 'svgo'
},
entry: magicFile(`
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => navigator.serviceWorker.register('/sw.js'));
}
require('${process.env.PWD}/src/index.js')
`),
output: {
filename: 'main.js',
path: path.join(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [
{
loader: 'elm-hot-webpack-loader',
options: {
debug: argv.mode != 'production',
}
},
{
loader: 'elm-webpack-loader',
options: {
optimize: argv.mode == 'production',
debug: argv.mode != 'production',
},
},
],
},
{
test: /\.html$/,
loader: 'html-loader',
options: {
minimize: true,
...htmlMin
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
devServer: {
inline: true,
hot: true,
stats: 'errors-only'
},
optimization: {
minimize: argv.mode == 'production',
minimizer: [
new TerserPlugin({ terserOptions: jsMin }),
new TerserPlugin({ terserOptions: jsMin }),
],
},
plugins: [...plugins(env, argv), ...(argv.mode == 'production' ? productionPlugins : [])],
})