mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-31 10:20:55 +00:00
The Great Webpack Update.
* Update to version 4 of webpack. * For that matter, update *every dependency* to the latest available version. * Remove the babel build target for Edge, as it doesn't seem to be necessary with webpack 4 and tenser. * Add support for optional chaining and nullish coalescing via Babel transformations. * Update the clips domain version to work better. Or at all, really. * Remove unused code from i18n. * Remove the last `<style>` from vue component files. They don't work that way now anyways. * Fix a bug in Raven's report handler. * Fix a bug with the menu button in browsers that don't understand `:scope` within `querySelector()`.
This commit is contained in:
parent
567708b7f1
commit
014eb203c3
31 changed files with 3106 additions and 5715 deletions
|
@ -3,11 +3,11 @@ const merge = require('webpack-merge');
|
|||
const common = require('./webpack.web.common.js');
|
||||
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const CleanPlugin = require('clean-webpack-plugin');
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
||||
|
||||
const uglify = require('uglify-es');
|
||||
const Terser = require('terser');
|
||||
|
||||
// Get Git info
|
||||
|
||||
|
@ -15,24 +15,25 @@ const commit_hash = require('child_process').execSync('git rev-parse HEAD').toSt
|
|||
|
||||
/* global module Buffer */
|
||||
|
||||
const config = module.exports = merge(common, {
|
||||
module.exports = merge(common, {
|
||||
mode: 'production',
|
||||
devtool: 'source-map',
|
||||
|
||||
plugins: [
|
||||
new CleanPlugin(['dist']),
|
||||
new UglifyJSPlugin({
|
||||
sourceMap: true,
|
||||
uglifyOptions: {
|
||||
compress: {
|
||||
keep_fnames: true,
|
||||
keep_classnames: true
|
||||
},
|
||||
mangle: {
|
||||
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)
|
||||
}),
|
||||
|
@ -42,7 +43,7 @@ const config = module.exports = merge(common, {
|
|||
to: 'script.min.js',
|
||||
transform: content => {
|
||||
const text = content.toString('utf8');
|
||||
const minified = uglify.minify(text);
|
||||
const minified = Terser.minify(text);
|
||||
return (minified && minified.code) ? Buffer.from(minified.code) : content;
|
||||
}
|
||||
}
|
||||
|
@ -61,21 +62,4 @@ const config = module.exports = merge(common, {
|
|||
publicPath: '//cdn.frankerfacez.com/static/',
|
||||
filename: '[name].[hash].js'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// This is why we can't have nice things.
|
||||
// Why can't I just access process.env.NODE_ENV from
|
||||
// one of these files when I set it with webpack's
|
||||
// CLI? So stupid.
|
||||
//
|
||||
// So here we go.
|
||||
// This is crap.
|
||||
// But it works.
|
||||
|
||||
for(const rule of config.module.rules) {
|
||||
if ( Array.isArray(rule.use) )
|
||||
for(const use of rule.use)
|
||||
if ( use.options && use.options.name && use.options.name.startsWith('[name].') )
|
||||
use.options.name = `[name].[hash].${use.options.name.slice(7)}`;
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue