mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-26 15:54:23 +00:00
8f5fdab5bf
* Update react-* to v16.7.0 * Upgrade react-hotkeys to v1.1.4 * Update react-intl to v2.7.2 * Update react-select to v2.2.0 * Update react-swipeable-views to v0.13.0 * Upgrade react-textarea-autosize to v7.1.0 * Upgrade redux to v4.0.1 * Upgrade reselect to v4.0.0 * Update raf to v3.4.1 * Update enzyme to v3.8.0 * Update rails-ujs to v5.2.2 * Update axios to v0.18.0 * Update http-link-header to v1.0.2 * Update rellax to v1.7.1 * Update intersection-observer to v0.5.1 * Update stringz to v1.0.0 * Upgrade babel-eslint to v10.0.1 * Update @babel/* to v7.2.x * Update babel-plugin-react-intl to v3.0.1 * Update babel-plugin-transform-react-remove-prop-types to v0.4.21 * Upgrade dotenv to v6.2.0 * Update express to v4.16.4 * Update webpack to v4.28.3 * Upgrade autoprefixer to v9.4.3 * Update babel-loader to v8.0.4 * Upgrade css-loader to v2.1.0 * Upgrade file-loader to v3.0.1 * Update marky to v1.2.1 * Update mini-css-extract-plugin to v0.5.0 * Update offline-plugin to v5.0.6 * Update style-loader to v0.23.1 * Update eslint-plugin-jsx-a11y to v6.1.2 * yarn upgrade * fix * Replace webpack-manifest-plugin to webpack-assets-manifest * Replace node-zopfli to @gfz/zopfli * Remove monkey-patch for http-link-header
121 lines
3.6 KiB
JavaScript
121 lines
3.6 KiB
JavaScript
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
|
|
|
const merge = require('webpack-merge');
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
|
const CompressionPlugin = require('compression-webpack-plugin');
|
|
const zopfli = require('@gfx/zopfli');
|
|
const sharedConfig = require('./shared.js');
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
const OfflinePlugin = require('offline-plugin');
|
|
const { publicPath } = require('./configuration.js');
|
|
const path = require('path');
|
|
const { URL } = require('url');
|
|
|
|
let attachmentHost;
|
|
|
|
if (process.env.S3_ENABLED === 'true') {
|
|
if (process.env.S3_ALIAS_HOST || process.env.S3_CLOUDFRONT_HOST) {
|
|
attachmentHost = process.env.S3_ALIAS_HOST || process.env.S3_CLOUDFRONT_HOST;
|
|
} else {
|
|
attachmentHost = process.env.S3_HOSTNAME || `s3-${process.env.S3_REGION || 'us-east-1'}.amazonaws.com`;
|
|
}
|
|
} else if (process.env.SWIFT_ENABLED === 'true') {
|
|
const { host } = new URL(process.env.SWIFT_OBJECT_URL);
|
|
attachmentHost = host;
|
|
} else {
|
|
attachmentHost = null;
|
|
}
|
|
|
|
module.exports = merge(sharedConfig, {
|
|
mode: 'production',
|
|
|
|
output: {
|
|
filename: '[name]-[chunkhash].js',
|
|
chunkFilename: '[name]-[chunkhash].js',
|
|
},
|
|
|
|
devtool: 'source-map', // separate sourcemap file, suitable for production
|
|
stats: 'normal',
|
|
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new UglifyJsPlugin({
|
|
cache: true,
|
|
parallel: true,
|
|
sourceMap: true,
|
|
|
|
uglifyOptions: {
|
|
compress: {
|
|
warnings: false,
|
|
},
|
|
|
|
output: {
|
|
comments: false,
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
},
|
|
|
|
plugins: [
|
|
new CompressionPlugin({
|
|
algorithm(input, compressionOptions, callback) {
|
|
return zopfli.gzip(input, compressionOptions, callback);
|
|
},
|
|
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf)$/,
|
|
}),
|
|
new BundleAnalyzerPlugin({ // generates report.html and stats.json
|
|
analyzerMode: 'static',
|
|
generateStatsFile: true,
|
|
statsOptions: {
|
|
// allows usage with http://chrisbateman.github.io/webpack-visualizer/
|
|
chunkModules: true,
|
|
},
|
|
openAnalyzer: false,
|
|
logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout
|
|
}),
|
|
new OfflinePlugin({
|
|
publicPath: publicPath, // sw.js must be served from the root to avoid scope issues
|
|
caches: {
|
|
main: [':rest:'],
|
|
additional: [':externals:'],
|
|
optional: [
|
|
'**/locale_*.js', // don't fetch every locale; the user only needs one
|
|
'**/*_polyfills-*.js', // the user may not need polyfills
|
|
'**/*.woff2', // the user may have system-fonts enabled
|
|
// images/audio can be cached on-demand
|
|
'**/*.png',
|
|
'**/*.jpg',
|
|
'**/*.jpeg',
|
|
'**/*.svg',
|
|
'**/*.mp3',
|
|
'**/*.ogg',
|
|
],
|
|
},
|
|
externals: [
|
|
'/emoji/1f602.svg', // used for emoji picker dropdown
|
|
'/emoji/sheet_10.png', // used in emoji-mart
|
|
],
|
|
excludes: [
|
|
'**/*.gz',
|
|
'**/*.map',
|
|
'stats.json',
|
|
'report.html',
|
|
// any browser that supports ServiceWorker will support woff2
|
|
'**/*.eot',
|
|
'**/*.ttf',
|
|
'**/*-webfont-*.svg',
|
|
'**/*.woff',
|
|
],
|
|
ServiceWorker: {
|
|
entry: `imports-loader?ATTACHMENT_HOST=>${encodeURIComponent(JSON.stringify(attachmentHost))}!${encodeURI(path.join(__dirname, '../../app/javascript/mastodon/service_worker/entry.js'))}`,
|
|
cacheName: 'mastodon',
|
|
output: '../assets/sw.js',
|
|
publicPath: '/sw.js',
|
|
minify: true,
|
|
},
|
|
}),
|
|
],
|
|
});
|