mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-12 09:00:54 +00:00
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
68 lines
No EOL
1.5 KiB
JavaScript
68 lines
No EOL
1.5 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();
|
|
|
|
/* global module Buffer */
|
|
|
|
const minifier = content => {
|
|
const text = content.toString('utf8');
|
|
const minified = Terser.minify(text);
|
|
return (minified && minified.code) ? Buffer.from(minified.code) : content;
|
|
};
|
|
|
|
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: './src/entry.js',
|
|
to: 'script.min.js',
|
|
transform: minifier
|
|
}
|
|
]),
|
|
new WebpackManifestPlugin({
|
|
publicPath: '',
|
|
map: data => {
|
|
if ( data.name.endsWith('.scss') )
|
|
data.name = `${data.name.slice(0, -5)}.css`;
|
|
|
|
return data;
|
|
}
|
|
})
|
|
],
|
|
|
|
output: {
|
|
publicPath: '//cdn.frankerfacez.com/static/',
|
|
filename: '[name].[hash].js'
|
|
}
|
|
}); |