Cleaner webpack config

This commit is contained in:
dangered wolf 2022-08-17 04:58:19 -04:00
parent 58e1f08e35
commit 8f31ae0609
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
2 changed files with 29 additions and 45 deletions

View file

@ -88,7 +88,7 @@ const statusRequest = async (
flags, flags,
language language
); );
/* Complete responses are normally sent just by errors. Normal embeds send a `text` value. */ /* Complete responses are normally sent just by errors. Normal embeds send a `text` value. */
if (statusResponse.response) { if (statusResponse.response) {
console.log('handleStatus sent response'); console.log('handleStatus sent response');
@ -120,7 +120,10 @@ const statusRequest = async (
/* A human has clicked a fxtwitter.com/:screen_name/status/:id link! /* A human has clicked a fxtwitter.com/:screen_name/status/:id link!
Obviously we just need to redirect to the Tweet directly.*/ Obviously we just need to redirect to the Tweet directly.*/
console.log('Matched human UA', userAgent); console.log('Matched human UA', userAgent);
return Response.redirect(`${Constants.TWITTER_ROOT}/${handle}/status/${id?.match(/\d{2,20}/)?.[0]}`, 302); return Response.redirect(
`${Constants.TWITTER_ROOT}/${handle}/status/${id?.match(/\d{2,20}/)?.[0]}`,
302
);
} }
}; };
@ -316,8 +319,9 @@ const sentryWrapper = async (event: FetchEvent, test = false): Promise<void> =>
/* We use Toucan for Sentry. Toucan is a Sentry SDK designed for Cloudflare Workers / DOs */ /* We use Toucan for Sentry. Toucan is a Sentry SDK designed for Cloudflare Workers / DOs */
sentry = new Toucan({ sentry = new Toucan({
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
context: event, /* Includes 'waitUntil', which is essential for Sentry logs to be delivered. context: event,
Also includes 'request' -- no need to set it separately. */ /* event includes 'waitUntil', which is essential for Sentry logs to be delivered.
Also includes 'request' -- no need to set it separately. */
allowedHeaders: /(.*)/, allowedHeaders: /(.*)/,
allowedSearchParams: /(.*)/, allowedSearchParams: /(.*)/,
release: RELEASE_NAME, release: RELEASE_NAME,

View file

@ -17,42 +17,28 @@ const releaseName = `fixtweet-${gitBranch}-${gitCommit}-${new Date()
require('dotenv').config(); require('dotenv').config();
let envVariables = [
'BRANDING_NAME',
'BRANDING_NAME_DISCORD',
'DIRECT_MEDIA_DOMAINS',
'HOST_URL',
'REDIRECT_URL',
'EMBED_URL',
'MOSAIC_DOMAIN_LIST',
'API_HOST_LIST',
'SENTRY_DSN',
'DEPRECATED_DOMAIN_LIST',
'DEPRECATED_DOMAIN_EPOCH'
];
let plugins = [ let plugins = [
new webpack.DefinePlugin({ ...envVariables.map(envVar => {
BRANDING_NAME: `'${process.env.BRANDING_NAME}'` return new webpack.DefinePlugin({
}), [envVar]: JSON.stringify(process.env[envVar])
new webpack.DefinePlugin({ });
BRANDING_NAME_DISCORD: `'${process.env.BRANDING_NAME_DISCORD}'`
}),
new webpack.DefinePlugin({
DIRECT_MEDIA_DOMAINS: `'${process.env.DIRECT_MEDIA_DOMAINS}'`
}),
new webpack.DefinePlugin({
HOST_URL: `'${process.env.HOST_URL}'`
}),
new webpack.DefinePlugin({
REDIRECT_URL: `'${process.env.REDIRECT_URL}'`
}),
new webpack.DefinePlugin({
EMBED_URL: `'${process.env.EMBED_URL}'`
}),
new webpack.DefinePlugin({
MOSAIC_DOMAIN_LIST: `'${process.env.MOSAIC_DOMAIN_LIST}'`
}),
new webpack.DefinePlugin({
API_HOST_LIST: `'${process.env.API_HOST_LIST}'`
}),
new webpack.DefinePlugin({
SENTRY_DSN: `'${process.env.SENTRY_DSN}'`
}), }),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
RELEASE_NAME: `'${releaseName}'` RELEASE_NAME: `'${releaseName}'`
}),
new webpack.DefinePlugin({
DEPRECATED_DOMAIN_LIST: `'${process.env.DEPRECATED_DOMAIN_LIST}'`
}),
new webpack.DefinePlugin({
DEPRECATED_DOMAIN_EPOCH: `'${process.env.DEPRECATED_DOMAIN_EPOCH}'`
}) })
]; ];
@ -69,9 +55,7 @@ if (process.env.SENTRY_AUTH_TOKEN) {
} }
module.exports = { module.exports = {
entry: { entry: { worker: './src/server.ts' },
worker: './src/server.ts'
},
target: 'webworker', target: 'webworker',
devtool: 'source-map', devtool: 'source-map',
output: { output: {
@ -84,17 +68,13 @@ module.exports = {
fallback: { util: false } fallback: { util: false }
}, },
plugins: plugins, plugins: plugins,
optimization: { optimization: { mangleExports: false },
mangleExports: 'size'
},
module: { module: {
rules: [ rules: [
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
loader: 'ts-loader', loader: 'ts-loader',
options: { options: { transpileOnly: true }
transpileOnly: true
}
} }
] ]
} }