1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 12:55:55 +00:00
FrankerFaceZ/webpack.web.prod.js
SirStendec 109898a10d 4.48.0
* Fixed: The `/ffz reload` command is now `/ffz:reload` to remove an undesirable behavior with Twitch's completion handling when backspacing.
* Fixed: Spaces being included in links when they shouldn't be.
* Fixed: Previews of emotes in chat when typing their names directly.
* Changed: Initial work on tracking the audio/video de-sync when using audio APIs for the compressor. This appears as a value in the stream latency metadata tool-tip, but currently drifts whenever the player is paused.
* Changed: Initial work on allowing the extension to be loaded from a bundled extension.
* API Changed: The load tracker now returns a list of reported loading keys when firing events.
2023-05-19 15:02:25 -04:00

77 lines
No EOL
1.8 KiB
JavaScript

const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.web.common.js');
const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const Terser = require('terser');
// Get Git info
const commit_hash = require('child_process').execSync('git rev-parse HEAD').toString().trim();
const FOR_EXTENSION = !! process.env.FFZ_EXTENSION;
/* global module Buffer */
const minifier = content => {
let text = content.toString('utf8');
if ( FOR_EXTENSION )
text = text.replace('__EXTENSION_PATH__', JSON.stringify(process.env.FFZ_EXTENSION));
const minified = Terser.minify(text);
return (minified && minified.code) ? Buffer.from(minified.code) : Buffer.from(text);
};
module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
optimization: {
concatenateModules: false,
minimizer: [
new TerserPlugin({
sourceMap: true,
terserOptions: {
keep_classnames: true,
keep_fnames: true
}
})
]
},
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({
__git_commit__: JSON.stringify(commit_hash)
}),
new CopyPlugin([
{
from: FOR_EXTENSION
? './src/entry_ext.js'
: './src/entry.js',
to: 'script.min.js',
transform: minifier
}
]),
new WebpackManifestPlugin({
publicPath: '',
map: data => {
if ( data.name.endsWith('.scss') )
data.name = `${data.name.substr(0,data.name.length - 5)}.css`;
return data;
}
})
],
output: {
publicPath: FOR_EXTENSION
? process.env.FFZ_EXTENSION
: '//cdn.frankerfacez.com/static/',
filename: FOR_EXTENSION
? '[name].js'
: '[name].[hash].js'
}
});