|
| 1 | +const imageminMozjpeg = require('imagemin-mozjpeg'); |
| 2 | +const ImageminPlugin = require('imagemin-webpack-plugin').default; |
| 3 | +const webpack = require('webpack'); |
| 4 | +const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 5 | +const UglifyJS = require('uglify-es'); |
| 6 | +const env_vars = require('../ENV_VARS'); |
| 7 | +const allowedConnections = require('../connections'); |
| 8 | + |
| 9 | +const sourceMapsConfig = { |
| 10 | + filename: 'sourcemaps/[file].map' |
| 11 | +}; |
| 12 | + |
| 13 | +const webpackConfig = { |
| 14 | + devtool: false, |
| 15 | + node: { |
| 16 | + process: true |
| 17 | + }, |
| 18 | + devServer: { |
| 19 | + https: true, |
| 20 | + host: 'localhost', |
| 21 | + hotOnly: true, |
| 22 | + port: 8080, |
| 23 | + headers: { |
| 24 | + 'Strict-Transport-Security': |
| 25 | + 'max-age=63072000; includeSubdomains; preload', |
| 26 | + 'Content-Security-Policy': |
| 27 | + "font-src 'self' data: js.intercomcdn.com:443; media-src js.intercomcdn.com:443 'self'; default-src 'self' blob:; frame-src 'self' www.walletlink.org:443 connect.trezor.io:443 intercom-sheets.com:443; img-src 'self' downloads.intercomcdn.com:443 gifs.intercomcdn.com:443 js.intercomcdn.com:443 images.ctfassets.net static.intercomassets.com:443 nft.mewapi.io:443 mewcard.mewapi.io:443 img.mewapi.io:443 app.lokalise.com:443 data: blob: ; script-src 'unsafe-eval' 'unsafe-inline' blob: https:; style-src 'self' 'unsafe-inline' https:; object-src 'none'; connect-src " + |
| 28 | + allowedConnections.join(' ') + |
| 29 | + ';', |
| 30 | + 'X-Content-Type-Options': 'nosniff', |
| 31 | + 'X-Frame-Options': 'DENY', |
| 32 | + 'X-XSS-Protection': '1; mode=block', |
| 33 | + 'Referrer-Policy': 'same-origin' |
| 34 | + } |
| 35 | + }, |
| 36 | + plugins: [ |
| 37 | + new webpack.SourceMapDevToolPlugin(sourceMapsConfig), |
| 38 | + new webpack.NormalModuleReplacementPlugin(/^any-promise$/, 'bluebird'), |
| 39 | + new ImageminPlugin({ |
| 40 | + disable: process.env.NODE_ENV !== 'production', |
| 41 | + test: /\.(jpe?g|png|gif|svg)$/i, |
| 42 | + pngquant: { |
| 43 | + quality: '100' |
| 44 | + }, |
| 45 | + plugins: [ |
| 46 | + imageminMozjpeg({ |
| 47 | + quality: 100, |
| 48 | + progressive: true |
| 49 | + }) |
| 50 | + ] |
| 51 | + }), |
| 52 | + new CopyWebpackPlugin({ |
| 53 | + patterns: [ |
| 54 | + { from: 'security.txt', to: '.well-known/security.txt' }, |
| 55 | + { |
| 56 | + from: 'public', |
| 57 | + transform: function (content, filePath) { |
| 58 | + if (filePath.split('.').pop() === ('js' || 'JS')) |
| 59 | + return UglifyJS.minify(content.toString()).code; |
| 60 | + return content; |
| 61 | + } |
| 62 | + } |
| 63 | + ] |
| 64 | + }), |
| 65 | + new webpack.DefinePlugin(env_vars) |
| 66 | + ], |
| 67 | + optimization: { |
| 68 | + splitChunks: { |
| 69 | + minSize: 1000000, |
| 70 | + maxSize: 20000000 |
| 71 | + } |
| 72 | + } |
| 73 | +}; |
| 74 | + |
| 75 | +module.exports = { webpackConfig, sourceMapsConfig, env_vars }; |
0 commit comments